Skip to content

Commit

Permalink
Consider mutes during push notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
ekzyis committed Dec 18, 2023
1 parent bd500f3 commit c48cec0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/push-notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down

0 comments on commit c48cec0

Please sign in to comment.