Skip to content

Commit 71c4b3c

Browse files
committed
Update profile avatar for gravatar
1 parent db42a2a commit 71c4b3c

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ A basic HackerNews-like clone where posts can be submitted with url links and th
1717
- [graphql-code-generator](https://www.graphql-code-generator.com) - Generate code from your GraphQL schema and operations with a simple CLI
1818
- [gql-tag-operations-preset](https://www.graphql-code-generator.com/plugins/gql-tag-operations-preset) - This code gen preset generates typings for your inline gql function usages, without having to manually specify import statements for the documents
1919
- [urql](https://formidable.com/open-source/urql/) - A highly customizable and versatile GraphQL client
20+
- [Gravatar](https://en.gravatar.com) - Default avatar profile images from Gravatar
2021

2122
### Backend
2223

data/supabase/05-setup-user-profile-trigger.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ CREATE OR REPLACE FUNCTION public.handle_new_user()
55
AS $function$
66
begin
77
insert into public."Profile" (id, "avatarUrl", username)
8-
values (new.id, new.raw_user_meta_data->>'avatar_url', split_part(new.email, '@', 1) || '-' || floor(random() * 10000));
8+
values (new.id, 'https://www.gravatar.com/avatar/' || md5(new.email) || '?d=mp', split_part(new.email, '@', 1) || '-' || floor(random() * 10000));
99
return new;
1010
end;
1111
$function$
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
WITH a AS (
2+
SELECT
3+
id,
4+
'https://www.gravatar.com/avatar/' || md5(email) || '?d=mp' AS "avatarUrl",
5+
email
6+
FROM
7+
auth.users
8+
)
9+
UPDATE
10+
public. "Profile"
11+
SET
12+
"avatarUrl" = a. "avatarUrl"
13+
FROM
14+
a
15+
WHERE
16+
a.id = public. "Profile".id

0 commit comments

Comments
 (0)