fix: zapping too fast causes duplicate notifications (#1812)
* fix: zapping too fast causes duplicate notifications * add comment --------- Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com>
This commit is contained in:
parent
44d3748d5f
commit
466620ff05
@ -206,7 +206,17 @@ export async function nonCriticalSideEffects ({ invoice, actIds }, { models }) {
|
|||||||
where: invoice ? { invoiceId: invoice.id } : { id: { in: actIds } },
|
where: invoice ? { invoiceId: invoice.id } : { id: { in: actIds } },
|
||||||
include: { item: true }
|
include: { item: true }
|
||||||
})
|
})
|
||||||
notifyZapped({ models, item: itemAct.item }).catch(console.error)
|
// avoid duplicate notifications with the same zap amount
|
||||||
|
// by checking if there are any other pending acts on the item
|
||||||
|
const pendingActs = await models.itemAct.count({
|
||||||
|
where: {
|
||||||
|
itemId: itemAct.itemId,
|
||||||
|
createdAt: {
|
||||||
|
gt: itemAct.createdAt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (pendingActs === 0) notifyZapped({ models, item: itemAct.item }).catch(console.error)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function onFail ({ invoice }, { tx }) {
|
export async function onFail ({ invoice }, { tx }) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user