From d0bd12b410e87a8dc9530425dcf2b354203bbd21 Mon Sep 17 00:00:00 2001 From: Hazelnoot Date: Mon, 23 Jun 2025 16:08:18 -0400 Subject: [PATCH] fix note mutings not applying to websocket --- packages/backend/src/server/api/stream/Connection.ts | 5 ++++- packages/backend/src/server/api/stream/channel.ts | 12 ++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/server/api/stream/Connection.ts b/packages/backend/src/server/api/stream/Connection.ts index f46cc1880e..e89aefe6a7 100644 --- a/packages/backend/src/server/api/stream/Connection.ts +++ b/packages/backend/src/server/api/stream/Connection.ts @@ -46,6 +46,7 @@ export default class Connection { public userIdsWhoMeMutingRenotes: Set = new Set(); public userMutedInstances: Set = new Set(); public userMutedThreads: Set = new Set(); + public userMutedNotes: Set = new Set(); public myRecentReactions: Map = new Map(); public myRecentRenotes: Set = new Set(); public myRecentFavorites: Set = new Set(); @@ -84,7 +85,7 @@ export default class Connection { @bindThis public async fetch() { if (this.user == null) return; - const [userProfile, following, followingChannels, userIdsWhoMeMuting, userIdsWhoBlockingMe, userIdsWhoMeMutingRenotes, threadMutings, myRecentReactions, myRecentFavorites, myRecentRenotes] = await Promise.all([ + const [userProfile, following, followingChannels, userIdsWhoMeMuting, userIdsWhoBlockingMe, userIdsWhoMeMutingRenotes, threadMutings, noteMutings, myRecentReactions, myRecentFavorites, myRecentRenotes] = await Promise.all([ this.cacheService.userProfileCache.fetch(this.user.id), this.cacheService.userFollowingsCache.fetch(this.user.id), this.channelFollowingService.userFollowingChannelsCache.fetch(this.user.id), @@ -92,6 +93,7 @@ export default class Connection { this.cacheService.userBlockedCache.fetch(this.user.id), this.cacheService.renoteMutingsCache.fetch(this.user.id), this.cacheService.threadMutingsCache.fetch(this.user.id), + this.cacheService.noteMutingsCache.fetch(this.user.id), this.noteReactionsRepository.find({ where: { userId: this.user.id }, select: { noteId: true, reaction: true }, @@ -120,6 +122,7 @@ export default class Connection { this.userIdsWhoMeMutingRenotes = userIdsWhoMeMutingRenotes; this.userMutedInstances = new Set(userProfile.mutedInstances); this.userMutedThreads = threadMutings; + this.userMutedNotes = noteMutings; this.myRecentReactions = new Map(myRecentReactions.map(r => [r.noteId, r.reaction])); this.myRecentFavorites = new Set(myRecentFavorites.map(f => f.noteId )); this.myRecentRenotes = new Set(myRecentRenotes.map(r => r.renoteId )); diff --git a/packages/backend/src/server/api/stream/channel.ts b/packages/backend/src/server/api/stream/channel.ts index 34680cf6d8..7e0e3e0bc6 100644 --- a/packages/backend/src/server/api/stream/channel.ts +++ b/packages/backend/src/server/api/stream/channel.ts @@ -78,6 +78,13 @@ export default abstract class Channel { return this.connection.userMutedThreads; } + /** + * @deprecated use cacheService.noteMutingsCache to avoid stale data + */ + protected get userMutedNotes() { + return this.connection.userMutedNotes; + } + protected get followingChannels() { return this.connection.followingChannels; } @@ -134,6 +141,9 @@ export default abstract class Channel { // Muted thread if (this.userMutedThreads.has(note.threadId)) return true; + // Muted note + if (this.userMutedNotes.has(note.id)) return true; + // If it's a boost (pure renote) then we need to check the target as well if (isPackedPureRenote(note) && note.renote && this.isNoteMutedOrBlocked(note.renote)) return true; @@ -144,8 +154,6 @@ export default abstract class Channel { if (!this.following.has(note.userId)) return true; } - // TODO muted threads - return false; }