File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 11import { HOURS_OF_IMMUNITY , PAID_ACTION_PAYMENT_METHODS , USER_ID } from '@/lib/constants'
22import { msatsToSats , satsToMsats } from '@/lib/format'
33import { datePivot } from '@/lib/time'
4- import { notifyZapped } from '@/lib/webPush'
4+ import { notifyZapped , notifyInfected } from '@/lib/webPush'
55import { getInvoiceableWallets } from '@/wallets/server'
66import { Prisma } from '@prisma/client'
77
@@ -252,11 +252,15 @@ async function maybeInfectUser (itemAct, { tx }) {
252252 return
253253 }
254254
255- await tx . $queryRaw `
255+ const count = await tx . $executeRaw `
256256 INSERT INTO "Infection" ("itemActId", "infecteeId", "infectorId")
257257 VALUES (${ id } ::INTEGER, ${ toId } ::INTEGER, ${ fromId } ::INTEGER)
258258 ON CONFLICT ("infecteeId") DO NOTHING`
259259 await tx . user . update ( { where : { id : toId } , data : { infected : true } } )
260+
261+ if ( count > 0 ) {
262+ notifyInfected ( toId ) . catch ( console . error )
263+ }
260264}
261265
262266export async function nonCriticalSideEffects ( { invoice, actIds } , { models } ) {
Original file line number Diff line number Diff line change @@ -464,3 +464,14 @@ export async function notifyReminder ({ userId, item }) {
464464 itemId : item . id
465465 } )
466466}
467+
468+ export async function notifyInfected ( userId ) {
469+ try {
470+ await sendUserNotification ( userId , {
471+ title : 'you have been bitten by a zombie' ,
472+ body : 'You\'re feeling cold and clammy and you have a sudden desire to zap everyone ...'
473+ } )
474+ } catch ( err ) {
475+ log ( 'error sending infected notification:' , err )
476+ }
477+ }
You can’t perform that action at this time.
0 commit comments