The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
delete workspace if no links
Steven Teyb7a042c1c748
diff --git a/apps/web/app/(ee)/api/stripe/webhook/utils/detect-and-handle-fraudulent-failed-charge.ts b/apps/web/app/(ee)/api/stripe/webhook/utils/detect-and-handle-fraudulent-failed-charge.tsindex 0e0abfef74..91be086770 100644--- a/apps/web/app/(ee)/api/stripe/webhook/utils/detect-and-handle-fraudulent-failed-charge.ts+++ b/apps/web/app/(ee)/api/stripe/webhook/utils/detect-and-handle-fraudulent-failed-charge.ts@@ -108,20 +108,40 @@ export async function detectAndHandleFraudulentFailedCharge(});continue;}- // transfer ownership to legal user- await prisma.projectUsers.update({+ const linksCount = await prisma.link.count({where: {- userId_projectId: {- projectId: workspace.id,- userId: user.id,- },- },- data: {- userId: LEGAL_USER_ID,+ projectId: workspace.id,},});- // disable workspace links- await disableWorkspaceLinks(workspace.id);+ if (linksCount > 0) {+ // transfer ownership to legal user+ await prisma.projectUsers.update({+ where: {+ userId_projectId: {+ projectId: workspace.id,+ userId: user.id,+ },+ },+ data: {+ userId: LEGAL_USER_ID,+ },+ });+ console.log(+ `[detectAndHandleFraudulentFailedCharge]: Transferred ownership of workspace ${workspace.slug} to legal user ${LEGAL_USER_ID}`,+ );+ // disable workspace links+ await disableWorkspaceLinks(workspace.id);+ } else {+ // if workspace has no links, just delete it+ await prisma.project.delete({+ where: {+ id: workspace.id,+ },+ });+ console.log(+ `[detectAndHandleFraudulentFailedCharge]: Deleted workspace ${workspace.slug} because it has no links`,+ );+ }}} else {console.log(