mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-12 04:15:30 +00:00
Delete account join request when redeeming an invite (#352)
* delete account join request when redeeming an invite * fix account request fetch
This commit is contained in:
parent
cf8fdd94f6
commit
9d86052ff5
1 changed files with 19 additions and 0 deletions
|
|
@ -1147,6 +1147,25 @@ export const redeemInvite = async (inviteId: string): Promise<{ success: boolean
|
|||
}
|
||||
});
|
||||
|
||||
// Delete the account request if it exists since we've redeemed an invite
|
||||
const accountRequest = await tx.accountRequest.findUnique({
|
||||
where: {
|
||||
requestedById_orgId: {
|
||||
requestedById: user.id,
|
||||
orgId: invite.orgId,
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
if (accountRequest) {
|
||||
logger.info(`Deleting account request ${accountRequest.id} for user ${user.id} since they've redeemed an invite`);
|
||||
await tx.accountRequest.delete({
|
||||
where: {
|
||||
id: accountRequest.id,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (IS_BILLING_ENABLED) {
|
||||
const result = await incrementOrgSeatCount(invite.orgId, tx);
|
||||
if (isServiceError(result)) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue