diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2023-10-15 10:36:22 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-15 10:36:22 +0900 |
| commit | 3f4ee9840560d8c423111f1ab93b2e36218a1314 (patch) | |
| tree | a133afad107362fea5ac00ec8e30704d62a357b9 /packages/backend/src/server/api/stream/channels/home-timeline.ts | |
| parent | perf(backend): tweak populateMyReaction (diff) | |
| download | misskey-3f4ee9840560d8c423111f1ab93b2e36218a1314.tar.gz misskey-3f4ee9840560d8c423111f1ab93b2e36218a1314.tar.bz2 misskey-3f4ee9840560d8c423111f1ab93b2e36218a1314.zip | |
perf(backend): improve streaming api performance (#12033)
* wip
* Update NoteEntityService.ts
* wip
* wip
* wip
* wip
Diffstat (limited to 'packages/backend/src/server/api/stream/channels/home-timeline.ts')
| -rw-r--r-- | packages/backend/src/server/api/stream/channels/home-timeline.ts | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/packages/backend/src/server/api/stream/channels/home-timeline.ts b/packages/backend/src/server/api/stream/channels/home-timeline.ts index 24be590504..de755cccb9 100644 --- a/packages/backend/src/server/api/stream/channels/home-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/home-timeline.ts @@ -51,27 +51,10 @@ class HomeTimelineChannel extends Channel { // Ignore notes from instances the user has muted if (isInstanceMuted(note, new Set<string>(this.userProfile!.mutedInstances ?? []))) return; - if (['followers', 'specified'].includes(note.visibility)) { - note = await this.noteEntityService.pack(note.id, this.user!, { - detail: true, - }); - - if (note.isHidden) { - return; - } - } else { - // リプライなら再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, - }); - } + if (note.visibility === 'followers') { + if (!Object.hasOwn(this.following, note.userId)) return; + } else if (note.visibility === 'specified') { + if (!note.visibleUserIds!.includes(this.user!.id)) return; } // 関係ない返信は除外 @@ -90,6 +73,11 @@ class HomeTimelineChannel 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); |