From e3dc1c302d18bc9618dcd2eb0f99c1c59b438df2 Mon Sep 17 00:00:00 2001 From: 0xsysr3ll <31414959+0xSysR3ll@users.noreply.github.com> Date: Mon, 9 Feb 2026 15:34:13 +0100 Subject: [PATCH] fix(webpush): avoid querying push subs with empty user list (#2380) --- server/lib/notifications/agents/webpush.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/server/lib/notifications/agents/webpush.ts b/server/lib/notifications/agents/webpush.ts index 04adb242..6b98185d 100644 --- a/server/lib/notifications/agents/webpush.ts +++ b/server/lib/notifications/agents/webpush.ts @@ -260,13 +260,16 @@ class WebPushAgent shouldSendAdminNotification(type, user, payload) ); - const allSubs = await userPushSubRepository - .createQueryBuilder('pushSub') - .leftJoinAndSelect('pushSub.user', 'user') - .where('pushSub.userId IN (:...users)', { - users: manageUsers.map((user) => user.id), - }) - .getMany(); + const allSubs = + manageUsers.length > 0 + ? await userPushSubRepository + .createQueryBuilder('pushSub') + .leftJoinAndSelect('pushSub.user', 'user') + .where('pushSub.userId IN (:...users)', { + users: manageUsers.map((user) => user.id), + }) + .getMany() + : []; // We only want to send the custom notification when type is approved or declined // Otherwise, default to the normal notification