From 9ead8bb1f1680b522550f963502c83e2f99d1e96 Mon Sep 17 00:00:00 2001 From: Dustin Hildebrandt Date: Sat, 29 May 2021 03:29:53 -0500 Subject: [PATCH] feat(notif): prevent manage-request users receiving auto-approve notif from their requests (#1707) (#1709) Email and webpush agents will filter out these users. Discord agent won't @ them. --- server/lib/notifications/agents/discord.ts | 5 ++++- server/lib/notifications/agents/email.ts | 5 ++++- server/lib/notifications/agents/webpush.ts | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/server/lib/notifications/agents/discord.ts b/server/lib/notifications/agents/discord.ts index f88d8b887..c3089cdce 100644 --- a/server/lib/notifications/agents/discord.ts +++ b/server/lib/notifications/agents/discord.ts @@ -249,7 +249,10 @@ class DiscordAgent NotificationAgentKey.DISCORD, type ) && - user.settings?.discordId + user.settings?.discordId && + // Check if it's the user's own auto-approved request + (type !== Notification.MEDIA_AUTO_APPROVED || + user.id !== payload.request?.requestedBy.id) ) .map((user) => `<@${user.settings?.discordId}>`) .join(' '); diff --git a/server/lib/notifications/agents/email.ts b/server/lib/notifications/agents/email.ts index 56401c0d5..593543a52 100644 --- a/server/lib/notifications/agents/email.ts +++ b/server/lib/notifications/agents/email.ts @@ -208,7 +208,10 @@ class EmailAgent NotificationAgentKey.EMAIL, type ) ?? - true)) + true)) && + // Check if it's the user's own auto-approved request + (type !== Notification.MEDIA_AUTO_APPROVED || + user.id !== payload.request?.requestedBy.id) ) .map(async (user) => { logger.debug('Sending email notification', { diff --git a/server/lib/notifications/agents/webpush.ts b/server/lib/notifications/agents/webpush.ts index 6af5b2bbc..7c72d19d7 100644 --- a/server/lib/notifications/agents/webpush.ts +++ b/server/lib/notifications/agents/webpush.ts @@ -185,7 +185,10 @@ class WebPushAgent NotificationAgentKey.WEBPUSH, type ) ?? - true) + true) && + // Check if it's the user's own auto-approved request + (type !== Notification.MEDIA_AUTO_APPROVED || + user.id !== payload.request?.requestedBy.id) ); const allSubs = await userPushSubRepository