Only send push notification if referrer was updated (#1562)

This commit is contained in:
ekzyis 2024-11-09 21:00:07 +01:00 committed by GitHub
parent 72e2d19433
commit afb71012af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -77,8 +77,8 @@ function getCallbacks (req, res) {
if (req.cookies.sn_referrer && user?.id) {
const referrerId = await getReferrerId(req.cookies.sn_referrer)
if (referrerId && referrerId !== parseInt(user?.id)) {
await prisma.user.updateMany({ where: { id: user.id, referrerId: null }, data: { referrerId } })
notifyReferral(referrerId)
const { count } = await prisma.user.updateMany({ where: { id: user.id, referrerId: null }, data: { referrerId } })
if (count > 0) notifyReferral(referrerId)
}
}
}