diff --git a/packages/backend/src/core/entities/NoteEntityService.ts b/packages/backend/src/core/entities/NoteEntityService.ts index 1875f8310b..9fbe7235fa 100644 --- a/packages/backend/src/core/entities/NoteEntityService.ts +++ b/packages/backend/src/core/entities/NoteEntityService.ts @@ -422,6 +422,7 @@ export class NoteEntityService implements OnModuleInit { pollVotes: Map>; channels: Map; notes: Map; + mutedThreads: Set; }; }, ): Promise> { @@ -460,9 +461,11 @@ export class NoteEntityService implements OnModuleInit { const packedFiles = options?._hint_?.packedFiles; const packedUsers = options?._hint_?.packedUsers; + const threadId = note.threadId ?? note.id; + const packed: Packed<'Note'> = await awaitAll({ id: note.id, - threadId: note.threadId ?? note.id, + threadId, createdAt: this.idService.parse(note.id).date.toISOString(), updatedAt: note.updatedAt ? note.updatedAt.toISOString() : undefined, userId: note.userId, @@ -502,6 +505,8 @@ export class NoteEntityService implements OnModuleInit { poll: opts._hint_?.polls.get(note.id), myVotes: opts._hint_?.pollVotes.get(note.id)?.get(note.userId), }) : undefined, + isMuting: opts._hint_?.mutedThreads.has(threadId) + ?? (meId != null && this.cacheService.threadMutingsCache.fetch(meId).then(ms => ms.has(threadId))), ...(meId && Object.keys(reactions).length > 0 ? { myReaction: this.populateMyReaction({ @@ -649,7 +654,7 @@ export class NoteEntityService implements OnModuleInit { const fileIds = new Set(targetNotes.flatMap(n => n.fileIds)); const mentionedUsers = new Set(targetNotes.flatMap(note => note.mentions)); - const [{ bufferedReactions, myReactionsMap }, packedFiles, packedUsers, mentionHandles, userFollowings, userBlockers, polls, pollVotes, channels] = await Promise.all([ + const [{ bufferedReactions, myReactionsMap }, packedFiles, packedUsers, mentionHandles, userFollowings, userBlockers, polls, pollVotes, channels, mutedThreads] = await Promise.all([ // bufferedReactions & myReactionsMap this.getReactions(targetNotes, me), // packedFiles @@ -660,6 +665,7 @@ export class NoteEntityService implements OnModuleInit { // mentionHandles this.getUserHandles(Array.from(mentionedUsers)), // userFollowings + // TODO this might be wrong this.cacheService.userFollowingsCache.fetchMany(userIds).then(fs => new Map(fs)), // userBlockers this.cacheService.userBlockedCache.fetchMany(userIds).then(bs => new Map(bs)), @@ -684,6 +690,8 @@ export class NoteEntityService implements OnModuleInit { }, new Map>)), // channels this.getChannels(targetNotes), + // mutedThreads + me ? this.cacheService.threadMutingsCache.fetch(me.id) : new Set(), // (not returned) this.customEmojiService.prefetchEmojis(this.aggregateNoteEmojis(notes)), ]); @@ -702,6 +710,7 @@ export class NoteEntityService implements OnModuleInit { pollVotes, channels, notes: new Map(targetNotes.map(n => [n.id, n])), + mutedThreads, }, }))); } diff --git a/packages/backend/src/models/json-schema/note.ts b/packages/backend/src/models/json-schema/note.ts index 036bf1fc06..cfe6c425bd 100644 --- a/packages/backend/src/models/json-schema/note.ts +++ b/packages/backend/src/models/json-schema/note.ts @@ -173,6 +173,10 @@ export const packedNoteSchema = { }, }, }, + isMuting: { + type: 'boolean', + optional: false, nullable: false, + }, emojis: { type: 'object', optional: true, nullable: false, diff --git a/packages/misskey-js/src/autogen/types.ts b/packages/misskey-js/src/autogen/types.ts index e019df95ac..c6045c9c43 100644 --- a/packages/misskey-js/src/autogen/types.ts +++ b/packages/misskey-js/src/autogen/types.ts @@ -4701,6 +4701,7 @@ export type components = { votes: number; }[]; }) | null; + isMuting: boolean; emojis?: { [key: string]: string; };