From fd5833766d1659062df0752120df570ee2e9641c Mon Sep 17 00:00:00 2001 From: ekzyis Date: Fri, 20 Dec 2024 13:02:35 +0100 Subject: [PATCH] Fix redeeming of unlimited invites --- api/paidAction/inviteGift.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/paidAction/inviteGift.js b/api/paidAction/inviteGift.js index 0cc52cae3..c96f5c92d 100644 --- a/api/paidAction/inviteGift.js +++ b/api/paidAction/inviteGift.js @@ -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') } @@ -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