1
0
mirror of https://git.boykissers.com/pawkey/pawkey-sk.git synced 2025-12-20 04:04:16 +00:00

fix reaction emoji mapping in mastodon API

This commit is contained in:
Hazelnoot
2025-03-24 13:47:31 -04:00
parent ebc3abea54
commit dcdc249e77

View File

@@ -336,14 +336,18 @@ namespace MisskeyAPI {
};
export const mapReactions = (r: { [key: string]: number }, e: Record<string, string | undefined>, myReaction?: string): Array<MegalodonEntity.Reaction> => {
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],
}
})
}