Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions lib/webPush.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down