From b7d80edcbbf8a1203acf6b7983cfdfb6db2afc4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=82=E3=82=8F=E3=82=8F=E3=82=8F=E3=81=A8=E3=83=BC?= =?UTF-8?q?=E3=81=AB=E3=82=85?= <17376330+u1-liquid@users.noreply.github.com> Date: Wed, 25 Dec 2024 14:13:45 +0900 Subject: [PATCH] =?UTF-8?q?fix(cdn-caching):=20=E8=87=AA=E5=88=86=E3=81=AE?= =?UTF-8?q?=E3=83=AA=E3=82=A2=E3=82=AF=E3=82=B7=E3=83=A7=E3=83=B3=E3=81=8C?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E3=81=95=E3=82=8C=E3=81=AA=E3=81=84=E5=95=8F?= =?UTF-8?q?=E9=A1=8C=E3=82=92=E4=BF=AE=E6=AD=A3=20(MisskeyIO#851)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/server/api/stream/channels/antenna.ts | 14 +++++++---- .../src/server/api/stream/channels/channel.ts | 14 +++++++---- .../api/stream/channels/global-timeline.ts | 14 +++++++---- .../api/stream/channels/home-timeline.ts | 14 +++++++---- .../api/stream/channels/hybrid-timeline.ts | 14 +++++++---- .../api/stream/channels/local-timeline.ts | 14 +++++++---- .../api/stream/channels/role-timeline.ts | 14 +++++++---- .../server/api/stream/channels/user-list.ts | 14 +++++++---- packages/backend/test/utils.ts | 2 +- .../frontend/src/components/MkTimeline.vue | 25 ++++++++++--------- packages/frontend/src/scripts/merge.ts | 2 +- packages/misskey-js/etc/misskey-js.api.md | 16 ++++++------ packages/misskey-js/src/streaming.types.ts | 16 ++++++------ 13 files changed, 103 insertions(+), 70 deletions(-) diff --git a/packages/backend/src/server/api/stream/channels/antenna.ts b/packages/backend/src/server/api/stream/channels/antenna.ts index 462463815e..ad8caa506b 100644 --- a/packages/backend/src/server/api/stream/channels/antenna.ts +++ b/packages/backend/src/server/api/stream/channels/antenna.ts @@ -16,7 +16,7 @@ class AntennaChannel extends Channel { public static requireCredential = true as const; public static kind = 'read:account'; private antennaId: string; - private idOnly: boolean; + private minimize: boolean; constructor( private noteEntityService: NoteEntityService, @@ -32,7 +32,7 @@ class AntennaChannel extends Channel { public async init(params: any) { if (typeof params.antennaId !== 'string') return; this.antennaId = params.antennaId as string; - this.idOnly = !!(params.idOnly ?? false); + this.minimize = !!(params.minimize ?? false); // Subscribe stream this.subscriber.on(`antennaStream:${this.antennaId}`, this.onEvent); @@ -45,9 +45,13 @@ class AntennaChannel extends Channel { if (this.isNoteMutedOrBlocked(note)) return; - if (this.idOnly && ['public', 'home'].includes(note.visibility)) { - const idOnlyNote = { id: note.id }; - this.send('note', idOnlyNote); + if (this.minimize && ['public', 'home'].includes(note.visibility)) { + this.send('note', { + id: note.id, myReaction: note.myReaction, + poll: note.poll ? { choices: note.poll.choices } : undefined, + reply: note.reply ? { myReaction: note.reply.myReaction } : undefined, + renote: note.renote ? { myReaction: note.renote.myReaction } : undefined, + }); } else { this.connection.cacheNote(note); this.send('note', note); diff --git a/packages/backend/src/server/api/stream/channels/channel.ts b/packages/backend/src/server/api/stream/channels/channel.ts index 7437764083..84a968cc23 100644 --- a/packages/backend/src/server/api/stream/channels/channel.ts +++ b/packages/backend/src/server/api/stream/channels/channel.ts @@ -16,7 +16,7 @@ class ChannelChannel extends Channel { public static shouldShare = false; public static requireCredential = false as const; private channelId: string; - private idOnly: boolean; + private minimize: boolean; constructor( private noteEntityService: NoteEntityService, @@ -32,7 +32,7 @@ class ChannelChannel extends Channel { public async init(params: any) { if (typeof params.channelId !== 'string') return; this.channelId = params.channelId as string; - this.idOnly = !!(params.idOnly ?? false); + this.minimize = !!(params.minimize ?? false); // Subscribe stream this.subscriber.on('notesStream', this.onNote); @@ -51,9 +51,13 @@ class ChannelChannel extends Channel { } } - if (this.idOnly && ['public', 'home'].includes(note.visibility)) { - const idOnlyNote = { id: note.id }; - this.send('note', idOnlyNote); + if (this.minimize && ['public', 'home'].includes(note.visibility)) { + this.send('note', { + id: note.id, myReaction: note.myReaction, + poll: note.poll ? { choices: note.poll.choices } : undefined, + reply: note.reply ? { myReaction: note.reply.myReaction } : undefined, + renote: note.renote ? { myReaction: note.renote.myReaction } : undefined, + }); } else { this.connection.cacheNote(note); this.send('note', note); diff --git a/packages/backend/src/server/api/stream/channels/global-timeline.ts b/packages/backend/src/server/api/stream/channels/global-timeline.ts index 8b12a8b170..33a4677a8f 100644 --- a/packages/backend/src/server/api/stream/channels/global-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/global-timeline.ts @@ -19,7 +19,7 @@ class GlobalTimelineChannel extends Channel { public static requireCredential = false as const; private withRenotes: boolean; private withFiles: boolean; - private idOnly: boolean; + private minimize: boolean; constructor( private metaService: MetaService, @@ -40,7 +40,7 @@ class GlobalTimelineChannel extends Channel { this.withRenotes = !!(params.withRenotes ?? true); this.withFiles = !!(params.withFiles ?? false); - this.idOnly = !!(params.idOnly ?? false); + this.minimize = !!(params.minimize ?? false); // Subscribe events this.subscriber.on('notesStream', this.onNote); @@ -64,9 +64,13 @@ class GlobalTimelineChannel extends Channel { } } - if (this.idOnly && ['public', 'home'].includes(note.visibility)) { - const idOnlyNote = { id: note.id }; - this.send('note', idOnlyNote); + if (this.minimize && ['public', 'home'].includes(note.visibility)) { + this.send('note', { + id: note.id, myReaction: note.myReaction, + poll: note.poll ? { choices: note.poll.choices } : undefined, + reply: note.reply ? { myReaction: note.reply.myReaction } : undefined, + renote: note.renote ? { myReaction: note.renote.myReaction } : undefined, + }); } else { this.connection.cacheNote(note); this.send('note', note); 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 fedead59c5..c3d2d836f2 100644 --- a/packages/backend/src/server/api/stream/channels/home-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/home-timeline.ts @@ -18,7 +18,7 @@ class HomeTimelineChannel extends Channel { public static kind = 'read:account'; private withRenotes: boolean; private withFiles: boolean; - private idOnly: boolean; + private minimize: boolean; constructor( private noteEntityService: NoteEntityService, @@ -34,7 +34,7 @@ class HomeTimelineChannel extends Channel { public async init(params: JsonObject) { this.withRenotes = !!(params.withRenotes ?? true); this.withFiles = !!(params.withFiles ?? false); - this.idOnly = !!(params.idOnly ?? false); + this.minimize = !!(params.minimize ?? false); this.subscriber.on('notesStream', this.onNote); } @@ -88,9 +88,13 @@ class HomeTimelineChannel extends Channel { } } - if (this.idOnly && ['public', 'home'].includes(note.visibility)) { - const idOnlyNote = { id: note.id }; - this.send('note', idOnlyNote); + if (this.minimize && ['public', 'home'].includes(note.visibility)) { + this.send('note', { + id: note.id, myReaction: note.myReaction, + poll: note.poll ? { choices: note.poll.choices } : undefined, + reply: note.reply ? { myReaction: note.reply.myReaction } : undefined, + renote: note.renote ? { myReaction: note.renote.myReaction } : undefined, + }); } else { this.connection.cacheNote(note); this.send('note', note); diff --git a/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts b/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts index 1162cf1707..8bd22fbd65 100644 --- a/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts @@ -21,7 +21,7 @@ class HybridTimelineChannel extends Channel { private withRenotes: boolean; private withReplies: boolean; private withFiles: boolean; - private idOnly: boolean; + private minimize: boolean; constructor( private metaService: MetaService, @@ -43,7 +43,7 @@ class HybridTimelineChannel extends Channel { this.withRenotes = !!(params.withRenotes ?? true); this.withReplies = !!(params.withReplies ?? false); this.withFiles = !!(params.withFiles ?? false); - this.idOnly = !!(params.idOnly ?? false); + this.minimize = !!(params.minimize ?? false); // Subscribe events this.subscriber.on('notesStream', this.onNote); @@ -103,9 +103,13 @@ class HybridTimelineChannel extends Channel { } } - if (this.idOnly && ['public', 'home'].includes(note.visibility)) { - const idOnlyNote = { id: note.id }; - this.send('note', idOnlyNote); + if (this.minimize && ['public', 'home'].includes(note.visibility)) { + this.send('note', { + id: note.id, myReaction: note.myReaction, + poll: note.poll ? { choices: note.poll.choices } : undefined, + reply: note.reply ? { myReaction: note.reply.myReaction } : undefined, + renote: note.renote ? { myReaction: note.renote.myReaction } : undefined, + }); } else { this.connection.cacheNote(note); this.send('note', note); diff --git a/packages/backend/src/server/api/stream/channels/local-timeline.ts b/packages/backend/src/server/api/stream/channels/local-timeline.ts index aeb89ae9a0..904b15ca37 100644 --- a/packages/backend/src/server/api/stream/channels/local-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/local-timeline.ts @@ -20,7 +20,7 @@ class LocalTimelineChannel extends Channel { private withRenotes: boolean; private withReplies: boolean; private withFiles: boolean; - private idOnly: boolean; + private minimize: boolean; constructor( private metaService: MetaService, @@ -42,7 +42,7 @@ class LocalTimelineChannel extends Channel { this.withRenotes = !!(params.withRenotes ?? true); this.withReplies = !!(params.withReplies ?? false); this.withFiles = !!(params.withFiles ?? false); - this.idOnly = !!(params.idOnly ?? false); + this.minimize = !!(params.minimize ?? false); // Subscribe events this.subscriber.on('notesStream', this.onNote); @@ -74,9 +74,13 @@ class LocalTimelineChannel extends Channel { } } - if (this.idOnly && ['public', 'home'].includes(note.visibility)) { - const idOnlyNote = { id: note.id }; - this.send('note', idOnlyNote); + if (this.minimize && ['public', 'home'].includes(note.visibility)) { + this.send('note', { + id: note.id, myReaction: note.myReaction, + poll: note.poll ? { choices: note.poll.choices } : undefined, + reply: note.reply ? { myReaction: note.reply.myReaction } : undefined, + renote: note.renote ? { myReaction: note.renote.myReaction } : undefined, + }); } else { this.connection.cacheNote(note); this.send('note', note); diff --git a/packages/backend/src/server/api/stream/channels/role-timeline.ts b/packages/backend/src/server/api/stream/channels/role-timeline.ts index 2b99de71c9..5bf3b7db05 100644 --- a/packages/backend/src/server/api/stream/channels/role-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/role-timeline.ts @@ -16,7 +16,7 @@ class RoleTimelineChannel extends Channel { public static shouldShare = false; public static requireCredential = false as const; private roleId: string; - private idOnly: boolean; + private minimize: boolean; constructor( private noteEntityService: NoteEntityService, @@ -33,7 +33,7 @@ class RoleTimelineChannel extends Channel { public async init(params: JsonObject) { if (typeof params.roleId !== 'string') return; this.roleId = params.roleId; - this.idOnly = !!(params.idOnly ?? false); + this.minimize = !!(params.minimize ?? false); this.subscriber.on(`roleTimelineStream:${this.roleId}`, this.onEvent); } @@ -50,9 +50,13 @@ class RoleTimelineChannel extends Channel { if (this.isNoteMutedOrBlocked(note)) return; - if (this.idOnly && ['public', 'home'].includes(note.visibility)) { - const idOnlyNote = { id: note.id }; - this.send('note', idOnlyNote); + if (this.minimize && ['public', 'home'].includes(note.visibility)) { + this.send('note', { + id: note.id, myReaction: note.myReaction, + poll: note.poll ? { choices: note.poll.choices } : undefined, + reply: note.reply ? { myReaction: note.reply.myReaction } : undefined, + renote: note.renote ? { myReaction: note.renote.myReaction } : undefined, + }); } else { this.send('note', note); } diff --git a/packages/backend/src/server/api/stream/channels/user-list.ts b/packages/backend/src/server/api/stream/channels/user-list.ts index a9d58e411b..98d165e39b 100644 --- a/packages/backend/src/server/api/stream/channels/user-list.ts +++ b/packages/backend/src/server/api/stream/channels/user-list.ts @@ -22,7 +22,7 @@ class UserListChannel extends Channel { private listUsersClock: NodeJS.Timeout; private withFiles: boolean; private withRenotes: boolean; - private idOnly: boolean; + private minimize: boolean; constructor( private userListsRepository: UserListsRepository, @@ -43,7 +43,7 @@ class UserListChannel extends Channel { this.listId = params.listId; this.withFiles = !!(params.withFiles ?? false); this.withRenotes = !!(params.withRenotes ?? true); - this.idOnly = !!(params.idOnly ?? false); + this.minimize = !!(params.minimize ?? false); // Check existence and owner const listExist = await this.userListsRepository.exists({ @@ -120,9 +120,13 @@ class UserListChannel extends Channel { } } - if (this.idOnly && ['public', 'home'].includes(note.visibility)) { - const idOnlyNote = { id: note.id }; - this.send('note', idOnlyNote); + if (this.minimize && ['public', 'home'].includes(note.visibility)) { + this.send('note', { + id: note.id, myReaction: note.myReaction, + poll: note.poll ? { choices: note.poll.choices } : undefined, + reply: note.reply ? { myReaction: note.reply.myReaction } : undefined, + renote: note.renote ? { myReaction: note.renote.myReaction } : undefined, + }); } else { this.connection.cacheNote(note); this.send('note', note); diff --git a/packages/backend/test/utils.ts b/packages/backend/test/utils.ts index 2c337ffff9..a1fcf5df1c 100644 --- a/packages/backend/test/utils.ts +++ b/packages/backend/test/utils.ts @@ -415,7 +415,7 @@ export const waitFire = async (user: UserToken if (timer) clearTimeout(timer); res(true); } - }, { ...params, idOnly: false }); + }, { ...params, minimize: false }); } catch (e) { rej(e); } diff --git a/packages/frontend/src/components/MkTimeline.vue b/packages/frontend/src/components/MkTimeline.vue index d958f82973..35d00f4432 100644 --- a/packages/frontend/src/components/MkTimeline.vue +++ b/packages/frontend/src/components/MkTimeline.vue @@ -17,13 +17,14 @@ SPDX-License-Identifier: AGPL-3.0-only