From 4e401408e9a9d02b93d4710598184276f9d47737 Mon Sep 17 00:00:00 2001 From: Mar0xy Date: Sun, 24 Sep 2023 00:39:55 +0200 Subject: [PATCH] fix: megalodon not having checks for emojis --- packages/megalodon/src/misskey/api_client.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/megalodon/src/misskey/api_client.ts b/packages/megalodon/src/misskey/api_client.ts index a0b01030d..e4dd14045 100644 --- a/packages/megalodon/src/misskey/api_client.ts +++ b/packages/megalodon/src/misskey/api_client.ts @@ -136,7 +136,7 @@ namespace MisskeyAPI { avatar_static: u.avatarUrl, header: this.plcUrl, header_static: this.plcUrl, - emojis: u.emojis.map((e) => this.emoji(e)), + emojis: u.emojis && u.emojis.length > 0 ? u.emojis.map((e) => this.emoji(e)) : [], moved: null, fields: [], bot: false, @@ -322,9 +322,9 @@ namespace MisskeyAPI { plain_content: n.text ? n.text : null, created_at: n.createdAt, // Remove reaction emojis with names containing @ from the emojis list. - emojis: n.emojis + emojis: n.emojis && n.emojis.length > 0 ? n.emojis .filter((e) => e.name.indexOf("@") === -1) - .map((e) => this.emoji(e)), + .map((e) => this.emoji(e)) : [], replies_count: n.repliesCount, reblogs_count: n.renoteCount, favourites_count: this.getTotalReactions(n.reactions), @@ -343,7 +343,7 @@ namespace MisskeyAPI { language: null, pinned: null, // Use emojis list to provide URLs for emoji reactions. - reactions: this.mapReactions(n.emojis, n.reactions, n.myReaction), + reactions: n.emojis && n.emojis.length > 0 ? this.mapReactions(n.emojis, n.reactions, n.myReaction) : [], bookmarked: false, quote: n.renote && n.text ? this.note(n.renote, host) : null, };