Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

optimize deleteDomainAndLinks

Steven Tey3d247a25f422
diff --git a/apps/web/app/api/admin/ban/route.ts b/apps/web/app/api/admin/ban/route.ts
index bcbbdf5664..2f3163752b 100644
--- a/apps/web/app/api/admin/ban/route.ts
+++ b/apps/web/app/api/admin/ban/route.ts
@@ -51,7 +51,7 @@ export const POST = withAdmin(async ({ req }) => {
logo: project.logo || null,
}),
),
-
+ // delete user
prisma.user.delete({
where: {
id: user.id,
diff --git a/apps/web/lib/api/domains.ts b/apps/web/lib/api/domains.ts
index 1a59c7198c..d3b32d0569 100644
--- a/apps/web/lib/api/domains.ts
+++ b/apps/web/lib/api/domains.ts
@@ -230,6 +230,7 @@ export async function deleteDomainAndLinks(domain: string) {
domain: true,
key: true,
url: true,
+ image: true,
projectId: true,
tags: true,
},
@@ -265,7 +266,8 @@ export async function deleteDomainAndLinks(domain: string) {
link,
deleted: true,
}),
- storage.delete(`images/${link.id}`),
+ link.image?.startsWith(process.env.STORAGE_BASE_URL as string) &&
+ storage.delete(`images/${link.id}`),
]),
// remove the domain from Vercel
removeDomainFromVercel(domain),