From dcdc249e77d9a8402761e594d34f748208006ab2 Mon Sep 17 00:00:00 2001 From: Hazelnoot Date: Mon, 24 Mar 2025 13:47:31 -0400 Subject: [PATCH] fix reaction emoji mapping in mastodon API --- packages/megalodon/src/misskey/api_client.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/megalodon/src/misskey/api_client.ts b/packages/megalodon/src/misskey/api_client.ts index ce6c4aa6cc..4c975c4dfa 100644 --- a/packages/megalodon/src/misskey/api_client.ts +++ b/packages/megalodon/src/misskey/api_client.ts @@ -336,14 +336,18 @@ namespace MisskeyAPI { }; export const mapReactions = (r: { [key: string]: number }, e: Record, myReaction?: string): Array => { - return Object.keys(r).map(key => { + return Object.entries(r).map(([key, count]) => { const me = myReaction != null && key === myReaction; + + // Translate the emoji name - "r" mapping includes a leading/trailing ":" + const [,name] = key.match(/^:([^@:]+(?:@[^:]+)?):$/) ?? [null,key]; + return { - count: r[key], + count, me, - name: key, - url: e[key], - static_url: e[key], + name, + url: e[name], + static_url: e[name], } }) }