Skip to content

Commit 1dd1bcc

Browse files
committed
add referralReward types to earnings notification
1 parent 6c4fbb3 commit 1dd1bcc

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

lib/webPush.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,8 @@ export async function notifyEarner (userId, earnings) {
416416
if (earnings.COMMENT) body += `#${earnings.COMMENT.bestRank} among comments with ${fmt(earnings.COMMENT.msats)} in total\n`
417417
if (earnings.TIP_POST) body += `#${earnings.TIP_POST.bestRank} in post zapping with ${fmt(earnings.TIP_POST.msats)} in total\n`
418418
if (earnings.TIP_COMMENT) body += `#${earnings.TIP_COMMENT.bestRank} in comment zapping with ${fmt(earnings.TIP_COMMENT.msats)} in total\n`
419-
if (earnings.FOREVER_REFERRAL) body += `#${earnings.FOREVER_REFERRAL.bestRank} in referral rewards with ${fmt(earnings.FOREVER_REFERRAL.msats)} in total\n`
420-
if (earnings.ONE_DAY_REFERRAL) body += `#${earnings.ONE_DAY_REFERRAL.bestRank} in referral rewards with ${fmt(earnings.ONE_DAY_REFERRAL.msats)} in total`
419+
if (earnings.ONE_DAY_REFERRAL) body += `in referral rewards with ${fmt(earnings.ONE_DAY_REFERRAL)} in total\n`
420+
if (earnings.FOREVER_REFERRAL) body += `in lifetime referral rewards with ${fmt(earnings.FOREVER_REFERRAL.msats)} in total`
421421

422422
try {
423423
await sendUserNotification(userId, { title, tag, body })

worker/earn.js

+16
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,14 @@ export async function earn ({ name }) {
149149
type: 'FOREVER_REFERRAL',
150150
rank: earner.rank
151151
}, { models }))
152+
153+
const userN = notifications[earner.foreverReferrerId] || {}
154+
const prevMsats = userN.msats || 0
155+
const msats = foreverReferrerEarnings + prevMsats
156+
notifications[earner.foreverReferrerId] = {
157+
...userN,
158+
FOREVER_REFERRAL: msats
159+
}
152160
} else if (earner.oneDayReferrerId) {
153161
// if the person doesn't have a forever referrer yet, they give double to their one day referrer
154162
oneDayReferrerEarnings += foreverReferrerEarnings
@@ -162,6 +170,14 @@ export async function earn ({ name }) {
162170
type: 'ONE_DAY_REFERRAL',
163171
rank: earner.rank
164172
}, { models }))
173+
174+
const userN = notifications[earner.oneDayReferrerId] || {}
175+
const prevMsats = userN.msats || 0
176+
const msats = oneDayReferrerEarnings + prevMsats
177+
notifications[earner.oneDayReferrerId] = {
178+
...userN,
179+
ONE_DAY_REFERRAL: msats
180+
}
165181
}
166182
}
167183

0 commit comments

Comments
 (0)