From 3f4ee9840560d8c423111f1ab93b2e36218a1314 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 15 Oct 2023 10:36:22 +0900 Subject: perf(backend): improve streaming api performance (#12033) * wip * Update NoteEntityService.ts * wip * wip * wip * wip --- .../backend/src/server/api/stream/channels/channel.ts | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'packages/backend/src/server/api/stream/channels/channel.ts') diff --git a/packages/backend/src/server/api/stream/channels/channel.ts b/packages/backend/src/server/api/stream/channels/channel.ts index a01714e76d..e4c34e00ce 100644 --- a/packages/backend/src/server/api/stream/channels/channel.ts +++ b/packages/backend/src/server/api/stream/channels/channel.ts @@ -38,19 +38,6 @@ class ChannelChannel extends Channel { private async onNote(note: Packed<'Note'>) { if (note.channelId !== this.channelId) return; - // リプライなら再pack - if (note.replyId != null) { - note.reply = await this.noteEntityService.pack(note.replyId, this.user, { - detail: true, - }); - } - // Renoteなら再pack - if (note.renoteId != null) { - note.renote = await this.noteEntityService.pack(note.renoteId, this.user, { - detail: true, - }); - } - // 流れてきたNoteがミュートしているユーザーが関わるものだったら無視する if (isUserRelated(note, this.userIdsWhoMeMuting)) return; // 流れてきたNoteがブロックされているユーザーが関わるものだったら無視する @@ -58,6 +45,11 @@ class ChannelChannel extends Channel { if (note.renote && !note.text && isUserRelated(note, this.userIdsWhoMeMutingRenotes)) return; + if (this.user && note.renoteId && !note.text) { + const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renoteId, this.user.id); + note.renote!.myReaction = myRenoteReaction; + } + this.connection.cacheNote(note); this.send('note', note); -- cgit v1.2.3-freya