diff --git a/lib/webPush.js b/lib/webPush.js index 61a132ce1e..ecd7d49b44 100644 --- a/lib/webPush.js +++ b/lib/webPush.js @@ -102,6 +102,22 @@ async function sendUserNotification (userId, notification) { if (!userId) { throw new Error('user id is required') } + + const user = await models.user.findUnique({ where: { id: userId } }) + if (!user) return + + if (user.satsFilter > 0 && notification.itemId) { + const item = await models.item.findUnique({ + where: { id: notification.itemId }, + select: { cost: true, boost: true, msats: true } + }) + const sats = (item.cost || 0) + (item.boost || 0) + Math.floor(msatsToSats(item.msats || 0)) + if (sats < user.satsFilter) { + // respect satsFilter + return + } + } + notification.data ??= {} if (notification.itemId) { // legacy Push API notificationclick event needs data.url as the navigate key is consumed by the browser