diff --git a/packages/backend/src/core/ChannelMutingService.ts b/packages/backend/src/core/ChannelMutingService.ts index 041ac19305..6347972392 100644 --- a/packages/backend/src/core/ChannelMutingService.ts +++ b/packages/backend/src/core/ChannelMutingService.ts @@ -15,7 +15,7 @@ import { RedisKVCache } from '@/misc/cache.js'; @Injectable() export class ChannelMutingService { - public userMutingChannelsCache: RedisKVCache>; + public mutingChannelsCache: RedisKVCache>; constructor( @Inject(DI.redis) @@ -29,7 +29,7 @@ export class ChannelMutingService { private idService: IdService, private globalEventService: GlobalEventService, ) { - this.userMutingChannelsCache = new RedisKVCache>(this.redisClient, 'channelMutingChannels', { + this.mutingChannelsCache = new RedisKVCache>(this.redisClient, 'channelMutingChannels', { lifetime: 1000 * 60 * 30, // 30m memoryCacheLifetime: 1000 * 60, // 1m fetcher: (userId) => this.channelMutingRepository.find({ @@ -115,7 +115,7 @@ export class ChannelMutingService { requestUserId: MiUser['id'], targetChannelId: MiChannel['id'], }): Promise { - const mutedChannels = await this.userMutingChannelsCache.get(params.requestUserId); + const mutedChannels = await this.mutingChannelsCache.get(params.requestUserId); return (mutedChannels?.has(params.targetChannelId) ?? false); } @@ -173,7 +173,7 @@ export class ChannelMutingService { const userIds = [...new Set(expiredMutings.map(x => x.userId))]; for (const userId of userIds) { - this.userMutingChannelsCache.refresh(userId).then(); + this.mutingChannelsCache.refresh(userId).then(); } } @@ -185,11 +185,11 @@ export class ChannelMutingService { const { type, body } = obj.message as GlobalEvents['internal']['payload']; switch (type) { case 'muteChannel': { - this.userMutingChannelsCache.refresh(body.userId).then(); + this.mutingChannelsCache.refresh(body.userId).then(); break; } case 'unmuteChannel': { - this.userMutingChannelsCache.delete(body.userId).then(); + this.mutingChannelsCache.delete(body.userId).then(); break; } } @@ -198,7 +198,7 @@ export class ChannelMutingService { @bindThis public dispose(): void { - this.userMutingChannelsCache.dispose(); + this.mutingChannelsCache.dispose(); } @bindThis diff --git a/packages/backend/src/core/FanoutTimelineEndpointService.ts b/packages/backend/src/core/FanoutTimelineEndpointService.ts index b7534d6cb4..fcf6b5f84b 100644 --- a/packages/backend/src/core/FanoutTimelineEndpointService.ts +++ b/packages/backend/src/core/FanoutTimelineEndpointService.ts @@ -111,7 +111,7 @@ export class FanoutTimelineEndpointService { this.cacheService.renoteMutingsCache.fetch(ps.me.id), this.cacheService.userBlockedCache.fetch(ps.me.id), this.cacheService.userProfileCache.fetch(me.id).then(p => new Set(p.mutedInstances)), - ps.excludeMutedChannels ? this.channelMutingService.userMutingChannelsCache.fetch(me.id) : Promise.resolve(new Set()), + ps.excludeMutedChannels ? this.channelMutingService.mutingChannelsCache.fetch(me.id) : Promise.resolve(new Set()), ]); const parentFilter = filter; diff --git a/packages/backend/src/server/api/stream/Connection.ts b/packages/backend/src/server/api/stream/Connection.ts index e667f86604..63d13c04d9 100644 --- a/packages/backend/src/server/api/stream/Connection.ts +++ b/packages/backend/src/server/api/stream/Connection.ts @@ -39,7 +39,6 @@ export default class Connection { public userIdsWhoBlockingMe: Set = new Set(); public userIdsWhoMeMutingRenotes: Set = new Set(); public userMutedInstances: Set = new Set(); - public userMutedChannels: Set = new Set(); private fetchIntervalId: NodeJS.Timeout | null = null; constructor( @@ -71,7 +70,7 @@ export default class Connection { this.cacheService.userProfileCache.fetch(this.user.id), this.cacheService.userFollowingsCache.fetch(this.user.id), this.channelFollowingService.userFollowingChannelsCache.fetch(this.user.id), - this.channelMutingService.userMutingChannelsCache.fetch(this.user.id), + this.channelMutingService.mutingChannelsCache.fetch(this.user.id), this.cacheService.userMutingsCache.fetch(this.user.id), this.cacheService.userBlockedCache.fetch(this.user.id), this.cacheService.renoteMutingsCache.fetch(this.user.id), @@ -125,37 +124,16 @@ export default class Connection { const { type, body } = obj; switch (type) { - case 'readNotification': - this.onReadNotification(body); - break; - case 'subNote': - this.onSubscribeNote(body); - break; - case 's': - this.onSubscribeNote(body); - break; // alias - case 'sr': - this.onSubscribeNote(body); - this.readNote(body); - break; - case 'unsubNote': - this.onUnsubscribeNote(body); - break; - case 'un': - this.onUnsubscribeNote(body); - break; // alias - case 'connect': - this.onChannelConnectRequested(body); - break; - case 'disconnect': - this.onChannelDisconnectRequested(body); - break; - case 'channel': - this.onChannelMessageRequested(body); - break; - case 'ch': - this.onChannelMessageRequested(body); - break; // alias + case 'readNotification': this.onReadNotification(body); break; + case 'subNote': this.onSubscribeNote(body); break; + case 's': this.onSubscribeNote(body); break; // alias + case 'sr': this.onSubscribeNote(body); this.readNote(body); break; + case 'unsubNote': this.onUnsubscribeNote(body); break; + case 'un': this.onUnsubscribeNote(body); break; // alias + case 'connect': this.onChannelConnectRequested(body); break; + case 'disconnect': this.onChannelDisconnectRequested(body); break; + case 'channel': this.onChannelMessageRequested(body); break; + case 'ch': this.onChannelMessageRequested(body); break; // alias } } 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 7cd7bcf56d..3b6e678e0a 100644 --- a/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts +++ b/packages/backend/src/server/api/stream/channels/hybrid-timeline.ts @@ -63,7 +63,7 @@ class HybridTimelineChannel extends Channel { (note.channelId == null && Object.hasOwn(this.following, note.userId)) || (note.channelId == null && (note.user.host == null && note.visibility === 'public')) || (note.channelId != null && this.followingChannels.has(note.channelId)) || - (note.channelId != null && !isChannelRelated(note, this.mutingChannels)) + (note.channelId != null && isChannelRelated(note, this.mutingChannels)) )) return; if (note.visibility === 'followers') {