diff --git a/packages/backend/src/core/NotificationService.ts b/packages/backend/src/core/NotificationService.ts index 80b2bd726..e09859569 100644 --- a/packages/backend/src/core/NotificationService.ts +++ b/packages/backend/src/core/NotificationService.ts @@ -111,6 +111,11 @@ export class NotificationService implements OnApplicationShutdown { return null; } + const blockings = await this.cacheService.userBlockingCache.fetch(notifieeId); + if (blockings.has(notifierId)) { + return null; + } + if (recieveConfig?.type === 'following') { const isFollowing = await this.cacheService.userFollowingsCache.fetch(notifieeId).then(followings => Object.hasOwn(followings, notifierId)); if (!isFollowing) { diff --git a/packages/backend/src/core/entities/NotificationEntityService.ts b/packages/backend/src/core/entities/NotificationEntityService.ts index 6770bcd05..8053cae5a 100644 --- a/packages/backend/src/core/entities/NotificationEntityService.ts +++ b/packages/backend/src/core/entities/NotificationEntityService.ts @@ -270,11 +270,13 @@ export class NotificationEntityService implements OnModuleInit { #validateNotifier ( notification: T, userIdsWhoMeMutingWithNotification: Set, + userIdsWhoMeBlocking: Set, userMutedInstances: Set, notifiers: MiUser[], ): boolean { if (!('notifierId' in notification)) return true; if (userIdsWhoMeMutingWithNotification.has(notification.notifierId)) return false; + if (userIdsWhoMeBlocking.has(notification.notifierId)) return false; const notifier = notifiers.find(x => x.id === notification.notifierId) ?? null; @@ -304,9 +306,11 @@ export class NotificationEntityService implements OnModuleInit { ): Promise { const [ userIdsWhoMeMutingWithNotification, + userIdsWhoMeBlocking, userMutedInstances, ] = (await Promise.allSettled([ this.cacheService.userMutingsWithNotificationCache.fetch(meId), + this.cacheService.userBlockingCache.fetch(meId), this.cacheService.userProfileCache.fetch(meId).then(p => new Set(p.mutedInstances)), ])).map(result => result.status === 'fulfilled' ? result.value : new Set()); @@ -316,7 +320,7 @@ export class NotificationEntityService implements OnModuleInit { }) : []; return ((await Promise.allSettled(notifications.map(async (notification) => { - const isValid = this.#validateNotifier(notification, userIdsWhoMeMutingWithNotification, userMutedInstances, notifiers); + const isValid = this.#validateNotifier(notification, userIdsWhoMeMutingWithNotification, userIdsWhoMeBlocking, userMutedInstances, notifiers); return isValid ? notification : null; }))).filter(result => result.status === 'fulfilled' && isNotNull(result.value)) .map(result => (result as PromiseFulfilledResult).value));