From 6ef1b1b1a206cb5033c8c7bc4295863426ed0d02 Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Tue, 7 Jan 2020 12:28:20 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=AB=E3=82=B9=E3=82=BF=E3=83=A0=E7=B5=B5?= =?UTF-8?q?=E6=96=87=E5=AD=97=E3=83=AA=E3=82=A2=E3=82=AF=E3=82=B7=E3=83=A7?= =?UTF-8?q?=E3=83=B3=E3=81=AE=E7=B5=B5=E6=96=87=E5=AD=97=E3=81=8CNote?= =?UTF-8?q?=E3=81=AB=E6=B7=BB=E4=BB=98=E3=81=95=E3=82=8C=E3=81=AA=E3=81=84?= =?UTF-8?q?=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3=20(#5686)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * カスタム絵文字リアクションの絵文字がNoteに添付されないのを修正 * ねんのため * 記述順 --- src/models/repositories/note.ts | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/models/repositories/note.ts b/src/models/repositories/note.ts index 03a50fece..bf5ebfdbf 100644 --- a/src/models/repositories/note.ts +++ b/src/models/repositories/note.ts @@ -129,6 +129,31 @@ export class NoteRepository extends Repository { }; } + async function populateEmojis(emojiNames: string[], noteUserHost: string | null, reactionNames: string[]) { + const where = [] as {}[]; + + if (emojiNames?.length > 0) { + where.push({ + name: In(emojiNames), + host: noteUserHost + }); + } + + if (reactionNames?.length > 0) { + where.push({ + name: In(reactionNames.map(x => x.replace(/:/g, ''))), + host: null + }); + } + + if (where.length === 0) return []; + + return Emojis.find({ + where, + select: ['name', 'host', 'url', 'aliases'] + }); + } + async function populateMyReaction() { const reaction = await NoteReactions.findOne({ userId: meId!, @@ -148,8 +173,6 @@ export class NoteRepository extends Repository { text = `【${note.name}】\n${(note.text || '').trim()}\n${note.uri}`; } - const reactionEmojis = unique(concat([note.emojis, Object.keys(note.reactions)])); - const packed = await awaitAll({ id: note.id, createdAt: note.createdAt.toISOString(), @@ -166,10 +189,7 @@ export class NoteRepository extends Repository { repliesCount: note.repliesCount, reactions: note.reactions, tags: note.tags.length > 0 ? note.tags : undefined, - emojis: reactionEmojis.length > 0 ? Emojis.find({ - name: In(reactionEmojis), - host: host - }) : [], + emojis: populateEmojis(note.emojis, host, Object.keys(note.reactions)), fileIds: note.fileIds, files: DriveFiles.packMany(note.fileIds), replyId: note.replyId,