Skip to content

Commit

Permalink
Fix redeeming of unlimited invites
Browse files Browse the repository at this point in the history
  • Loading branch information
ekzyis committed Dec 23, 2024
1 parent 8351a69 commit fd58337
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions api/paidAction/inviteGift.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export async function perform ({ id, userId }, { me, cost, tx }) {
where: { id, userId: me.id, revoked: false }
})

if (invite.giftedCount >= invite.limit) {
if (invite.limit && invite.giftedCount >= invite.limit) {
throw new Error('invite limit reached')
}

Expand All @@ -45,7 +45,7 @@ export async function perform ({ id, userId }, { me, cost, tx }) {
})

return await tx.invite.update({
where: { id, userId: me.id, giftedCount: { lt: invite.limit }, revoked: false },
where: { id, userId: me.id, revoked: false, ...(invite.limit ? { giftedCount: { lt: invite.limit } } : {}) },
data: {
giftedCount: {
increment: 1
Expand Down

0 comments on commit fd58337

Please sign in to comment.