From fe05ceca1ff09f8e053077ae9c8295cfadaf9011 Mon Sep 17 00:00:00 2001 From: Crimekillz Date: Tue, 26 Mar 2024 15:44:53 +0100 Subject: [PATCH] Pass reference to Note OBJ when creating notifications for Poll Vote and Poll End so muted threads can be resolved correctly and do not notify if voter is silenced --- .../backend/src/queue/processors/ended-poll-notification.ts | 1 + packages/backend/src/services/create-notification.ts | 2 +- packages/backend/src/services/note/polls/vote.ts | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/queue/processors/ended-poll-notification.ts b/packages/backend/src/queue/processors/ended-poll-notification.ts index 3bf010a1b..c652d6216 100644 --- a/packages/backend/src/queue/processors/ended-poll-notification.ts +++ b/packages/backend/src/queue/processors/ended-poll-notification.ts @@ -28,6 +28,7 @@ export async function endedPollNotification( for (const userId of userIds) { createNotification(userId, "pollEnded", { + note: note, noteId: note.id, }); } diff --git a/packages/backend/src/services/create-notification.ts b/packages/backend/src/services/create-notification.ts index d89cb8549..04cdac397 100644 --- a/packages/backend/src/services/create-notification.ts +++ b/packages/backend/src/services/create-notification.ts @@ -25,7 +25,7 @@ export async function createNotification( if ( data.notifierId && - ["mention", "reply", "renote", "quote", "reaction", "bite"].includes(type) + ["mention", "reply", "renote", "quote", "reaction", "bite", "pollVote"].includes(type) ) { const notifier = await Users.findOneBy({ id: data.notifierId }); // suppress if the notifier does not exist or is silenced. diff --git a/packages/backend/src/services/note/polls/vote.ts b/packages/backend/src/services/note/polls/vote.ts index 582af0b17..1016e6aa9 100644 --- a/packages/backend/src/services/note/polls/vote.ts +++ b/packages/backend/src/services/note/polls/vote.ts @@ -67,6 +67,7 @@ export default async function ( // Notify createNotification(note.userId, "pollVote", { notifierId: user.id, + note: note, noteId: note.id, choice: choice, }); @@ -79,6 +80,7 @@ export default async function ( for (const watcher of watchers) { createNotification(watcher.userId, "pollVote", { notifierId: user.id, + note: note, noteId: note.id, choice: choice, });