From 8b17ab77b4d7d4a87ee8dbfbaef983539d626c25 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 | 26 +++++++++---------- 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(+), 71 deletions(-) diff --git a/packages/backend/src/server/api/stream/channels/antenna.ts b/packages/backend/src/server/api/stream/channels/antenna.ts index 5c16cea60..7fd34ccfd 100644 --- a/packages/backend/src/server/api/stream/channels/antenna.ts +++ b/packages/backend/src/server/api/stream/channels/antenna.ts @@ -15,7 +15,7 @@ class AntennaChannel extends Channel { public static readonly requireCredential = true as const; public static readonly kind = 'read:account'; private antennaId: string; - private idOnly: boolean; + private minimize: boolean; constructor( private noteEntityService: NoteEntityService, @@ -30,7 +30,7 @@ class AntennaChannel extends Channel { @bindThis public async init(params: any) { 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); @@ -51,9 +51,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 94ffcd5d6..e97928c8d 100644 --- a/packages/backend/src/server/api/stream/channels/channel.ts +++ b/packages/backend/src/server/api/stream/channels/channel.ts @@ -15,7 +15,7 @@ class ChannelChannel extends Channel { public static readonly shouldShare = false; public static readonly requireCredential = false as const; private channelId: string; - private idOnly: boolean; + private minimize: boolean; constructor( private noteEntityService: NoteEntityService, @@ -30,7 +30,7 @@ class ChannelChannel extends Channel { @bindThis public async init(params: any) { this.channelId = params.channelId as string; - this.idOnly = params.idOnly ?? false; + this.minimize = params.minimize ?? false; // Subscribe stream this.subscriber.on('notesStream', this.onNote); @@ -57,9 +57,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 64f194160..d5f32c91f 100644 --- a/packages/backend/src/server/api/stream/channels/global-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/global-timeline.ts @@ -18,7 +18,7 @@ class GlobalTimelineChannel extends Channel { public static readonly requireCredential = false as const; private withRenotes: boolean; private withFiles: boolean; - private idOnly: boolean; + private minimize: boolean; constructor( private metaService: MetaService, @@ -39,7 +39,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); @@ -87,9 +87,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 3ee193522..0f983c977 100644 --- a/packages/backend/src/server/api/stream/channels/home-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/home-timeline.ts @@ -17,7 +17,7 @@ class HomeTimelineChannel extends Channel { public static readonly kind = 'read:account'; private withRenotes: boolean; private withFiles: boolean; - private idOnly: boolean; + private minimize: boolean; constructor( private noteEntityService: NoteEntityService, @@ -33,7 +33,7 @@ class HomeTimelineChannel extends Channel { public async init(params: any) { 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); } @@ -91,9 +91,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 20337f85b..8234d5c23 100644 --- a/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts @@ -20,7 +20,7 @@ class HybridTimelineChannel 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 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); @@ -105,9 +105,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 441b0132a..eae05fca6 100644 --- a/packages/backend/src/server/api/stream/channels/local-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/local-timeline.ts @@ -19,7 +19,7 @@ class LocalTimelineChannel extends Channel { private withRenotes: boolean; private withReplies: boolean; private withFiles: boolean; - private idOnly: boolean; + private minimize: boolean; constructor( private metaService: MetaService, @@ -41,7 +41,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); @@ -90,9 +90,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 3fb888571..746608c27 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 readonly shouldShare = false; public static readonly requireCredential = false as const; private roleId: string; - private idOnly: boolean; + private minimize: boolean; constructor( private noteEntityService: NoteEntityService, @@ -32,7 +32,7 @@ class RoleTimelineChannel extends Channel { @bindThis public async init(params: any) { this.roleId = params.roleId as string; - this.idOnly = params.idOnly ?? false; + this.minimize = params.minimize ?? false; this.subscriber.on(`roleTimelineStream:${this.roleId}`, this.onEvent); } @@ -73,9 +73,13 @@ class RoleTimelineChannel 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/user-list.ts b/packages/backend/src/server/api/stream/channels/user-list.ts index 651ab05f3..3faeaddc7 100644 --- a/packages/backend/src/server/api/stream/channels/user-list.ts +++ b/packages/backend/src/server/api/stream/channels/user-list.ts @@ -21,7 +21,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, @@ -41,7 +41,7 @@ class UserListChannel extends Channel { this.listId = params.listId as string; 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({ @@ -130,9 +130,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 6ef69f4d3..573cafad6 100644 --- a/packages/backend/test/utils.ts +++ b/packages/backend/test/utils.ts @@ -400,7 +400,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 9c7e4587d..cf451d4a0 100644 --- a/packages/frontend/src/components/MkTimeline.vue +++ b/packages/frontend/src/components/MkTimeline.vue @@ -18,12 +18,12 @@ SPDX-License-Identifier: AGPL-3.0-only