From c48cec008d5ecf8e48dcf78b6f1816cf893d549c Mon Sep 17 00:00:00 2001 From: ekzyis Date: Mon, 18 Dec 2023 17:24:05 +0100 Subject: [PATCH] Consider mutes during push notifications --- lib/push-notifications.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/push-notifications.js b/lib/push-notifications.js index 2f2b3af376..5264cc94c8 100644 --- a/lib/push-notifications.js +++ b/lib/push-notifications.js @@ -32,7 +32,8 @@ export const notifyItemParents = async ({ models, item, me }) => { try { const user = await models.user.findUnique({ where: { id: me?.id || ANON_USER_ID } }) const parents = await models.$queryRawUnsafe( - 'SELECT DISTINCT p."userId" FROM "Item" i JOIN "Item" p ON p.path @> i.path WHERE i.id = $1 and p."userId" <> $2', + 'SELECT DISTINCT p."userId" FROM "Item" i JOIN "Item" p ON p.path @> i.path WHERE i.id = $1 and p."userId" <> $2 ' + + 'AND NOT EXISTS (SELECT 1 FROM "Mute" m WHERE m."muterId" = p."userId" AND m."mutedId" = $1)', Number(item.parentId), Number(user.id)) Promise.allSettled( parents.map(({ userId }) => sendUserNotification(userId, {