summaryrefslogtreecommitdiff
path: root/src/models
diff options
context:
space:
mode:
authorMeiMei <30769358+mei23@users.noreply.github.com>2020-01-07 12:28:20 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2020-01-07 12:28:20 +0900
commit6ef1b1b1a206cb5033c8c7bc4295863426ed0d02 (patch)
tree750c76716269772025ef87286d9334163abb2705 /src/models
parentUpdate README.md [AUTOGEN] (#5680) (diff)
downloadmisskey-6ef1b1b1a206cb5033c8c7bc4295863426ed0d02.tar.gz
misskey-6ef1b1b1a206cb5033c8c7bc4295863426ed0d02.tar.bz2
misskey-6ef1b1b1a206cb5033c8c7bc4295863426ed0d02.zip
カスタム絵文字リアクションの絵文字がNoteに添付されないのを修正 (#5686)
* カスタム絵文字リアクションの絵文字がNoteに添付されないのを修正 * ねんのため * 記述順
Diffstat (limited to 'src/models')
-rw-r--r--src/models/repositories/note.ts32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/models/repositories/note.ts b/src/models/repositories/note.ts
index 03a50fecec..bf5ebfdbfe 100644
--- a/src/models/repositories/note.ts
+++ b/src/models/repositories/note.ts
@@ -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,