fix(cdn-caching): 自分のリアクションが表示されない問題を修正 (MisskeyIO#851)

This commit is contained in:
あわわわとーにゅ 2024-12-25 14:13:45 +09:00 committed by GitHub
parent 5073467f1d
commit 8b17ab77b4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 103 additions and 71 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -400,7 +400,7 @@ export const waitFire = async <C extends keyof misskey.Channels>(user: UserToken
if (timer) clearTimeout(timer);
res(true);
}
}, { ...params, idOnly: false });
}, { ...params, minimize: false });
} catch (e) {
rej(e);
}