カスタム絵文字リアクションの絵文字がNoteに添付されないのを修正 (#5686)

* カスタム絵文字リアクションの絵文字がNoteに添付されないのを修正

* ねんのため

* 記述順
This commit is contained in:
MeiMei 2020-01-07 12:28:20 +09:00 committed by syuilo
parent fc0e1955d7
commit 6ef1b1b1a2
1 changed files with 26 additions and 6 deletions

View File

@ -129,6 +129,31 @@ export class NoteRepository extends Repository<Note> {
};
}
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<Note> {
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<Note> {
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,