From 187c98e5acb4e20df263a914ae64c72a6414da60 Mon Sep 17 00:00:00 2001 From: Jacob Hall Date: Thu, 20 Feb 2025 15:09:48 -0500 Subject: [PATCH] do not notify mentioned users if a DM is not visible to them --- packages/backend/src/core/NoteCreateService.ts | 3 ++- packages/backend/src/core/NoteEditService.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts index 3bfced1d80..a907b4a42f 100644 --- a/packages/backend/src/core/NoteCreateService.ts +++ b/packages/backend/src/core/NoteCreateService.ts @@ -861,7 +861,8 @@ export class NoteCreateService implements OnApplicationShutdown { @bindThis private async createMentionedEvents(mentionedUsers: MinimumUser[], note: MiNote, nm: NotificationManager) { - for (const u of mentionedUsers.filter(u => this.userEntityService.isLocalUser(u))) { + // Only create mention events for local users, and users for whom the note is visible + for (const u of mentionedUsers.filter(u => (note.visibility !== 'specified' || note.visibleUserIds.some(x => x === u.id)) && this.userEntityService.isLocalUser(u))) { const isThreadMuted = await this.noteThreadMutingsRepository.exists({ where: { userId: u.id, diff --git a/packages/backend/src/core/NoteEditService.ts b/packages/backend/src/core/NoteEditService.ts index 453ad5d9d0..3972ed49f8 100644 --- a/packages/backend/src/core/NoteEditService.ts +++ b/packages/backend/src/core/NoteEditService.ts @@ -801,6 +801,7 @@ export class NoteEditService implements OnApplicationShutdown { // TODO why is this unused? @bindThis private async createMentionedEvents(mentionedUsers: MinimumUser[], note: MiNote, nm: NotificationManager) { + // FIXME only users the note is visible to should receive a notification, same as when a note is created for (const u of mentionedUsers.filter(u => this.userEntityService.isLocalUser(u))) { const isThreadMuted = await this.noteThreadMutingsRepository.exists({ where: {