From 00cd311c7d3fc7c3c8406b826bfc0cfcceb289b5 Mon Sep 17 00:00:00 2001 From: Naomi Ahmed Date: Tue, 27 Dec 2022 23:52:59 +0000 Subject: [PATCH 1/4] Fix emojis crashing when it's not found --- .../src/server/api/endpoints/compatibility/instance-info.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend/src/server/api/endpoints/compatibility/instance-info.ts b/packages/backend/src/server/api/endpoints/compatibility/instance-info.ts index 825119120e..40f83a5f0a 100644 --- a/packages/backend/src/server/api/endpoints/compatibility/instance-info.ts +++ b/packages/backend/src/server/api/endpoints/compatibility/instance-info.ts @@ -181,7 +181,7 @@ const getContact = async ( following_count: user.followingCount, statuses_count: user.notesCount, last_status_at: user.lastActiveDate?.toISOString(), - emojis: emojis ? user.emojis.map(e => ({ + emojis: emojis ? user.emojis.filter(e => e in emojis).map(e => ({ shortcode: e, static_url: `${config.url}/files/${emojis[e].publicUrl}`, url: `${config.url}/files/${emojis[e].publicUrl}`, From 200cd9f2ce30eb7c0469ffbfae2e2539e9eff55e Mon Sep 17 00:00:00 2001 From: Naomi Ahmed Date: Tue, 27 Dec 2022 23:59:46 +0000 Subject: [PATCH 2/4] Fix emoji urls being invalid --- .../src/server/api/endpoints/compatibility/instance-info.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/compatibility/instance-info.ts b/packages/backend/src/server/api/endpoints/compatibility/instance-info.ts index 40f83a5f0a..1fbb3c3c1f 100644 --- a/packages/backend/src/server/api/endpoints/compatibility/instance-info.ts +++ b/packages/backend/src/server/api/endpoints/compatibility/instance-info.ts @@ -183,8 +183,8 @@ const getContact = async ( last_status_at: user.lastActiveDate?.toISOString(), emojis: emojis ? user.emojis.filter(e => e in emojis).map(e => ({ shortcode: e, - static_url: `${config.url}/files/${emojis[e].publicUrl}`, - url: `${config.url}/files/${emojis[e].publicUrl}`, + static_url: emojis[e].publicUrl, + url: emojis[e].publicUrl, visible_in_picker: true, })) : [], }; From 9e6c7c57c4be25124f4ca91da0f9acc805c03e1e Mon Sep 17 00:00:00 2001 From: Naomi Ahmed Date: Wed, 28 Dec 2022 00:01:18 +0000 Subject: [PATCH 3/4] Mirror format in custom-emojis.ts --- .../src/server/api/endpoints/compatibility/instance-info.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend/src/server/api/endpoints/compatibility/instance-info.ts b/packages/backend/src/server/api/endpoints/compatibility/instance-info.ts index 1fbb3c3c1f..f416c4b395 100644 --- a/packages/backend/src/server/api/endpoints/compatibility/instance-info.ts +++ b/packages/backend/src/server/api/endpoints/compatibility/instance-info.ts @@ -184,7 +184,7 @@ const getContact = async ( emojis: emojis ? user.emojis.filter(e => e in emojis).map(e => ({ shortcode: e, static_url: emojis[e].publicUrl, - url: emojis[e].publicUrl, + url: emojis[e].originalUrl, visible_in_picker: true, })) : [], }; From c36274848db33673fd745eeb22d39e97be290f19 Mon Sep 17 00:00:00 2001 From: Naomi Ahmed Date: Wed, 28 Dec 2022 00:15:07 +0000 Subject: [PATCH 4/4] deduplicate emojis --- .../src/server/api/endpoints/compatibility/instance-info.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend/src/server/api/endpoints/compatibility/instance-info.ts b/packages/backend/src/server/api/endpoints/compatibility/instance-info.ts index f416c4b395..f73d8bf82f 100644 --- a/packages/backend/src/server/api/endpoints/compatibility/instance-info.ts +++ b/packages/backend/src/server/api/endpoints/compatibility/instance-info.ts @@ -181,7 +181,7 @@ const getContact = async ( following_count: user.followingCount, statuses_count: user.notesCount, last_status_at: user.lastActiveDate?.toISOString(), - emojis: emojis ? user.emojis.filter(e => e in emojis).map(e => ({ + emojis: emojis ? user.emojis.filter((e, i, a) => e in emojis && a.indexOf(e) == i).map(e => ({ shortcode: e, static_url: emojis[e].publicUrl, url: emojis[e].originalUrl,