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.

update the link cache on webhook deletion

Kiran Kb09bc57e3d37
diff --git a/apps/web/app/api/webhooks/[webhookId]/route.ts b/apps/web/app/api/webhooks/[webhookId]/route.ts
index ee1f59a4a1..d8a0cbbe00 100644
--- a/apps/web/app/api/webhooks/[webhookId]/route.ts
+++ b/apps/web/app/api/webhooks/[webhookId]/route.ts
@@ -161,15 +161,6 @@ export const DELETE = withWorkspace(
async ({ workspace, params }) => {
const { webhookId } = params;
- const linkWebhooks = await prisma.linkWebhook.findMany({
- where: {
- webhookId,
- },
- select: {
- linkId: true,
- },
- });
-
await prisma.webhook.delete({
where: {
id: webhookId,
@@ -197,12 +188,20 @@ export const DELETE = withWorkspace(
waitUntil(
(async () => {
- const linkIds = linkWebhooks.map((linkWebhook) => linkWebhook.linkId);
+ const linkWebhooks = await prisma.linkWebhook.findMany({
+ where: {
+ webhookId,
+ },
+ select: {
+ linkId: true,
+ },
+ });
+
+ const linkIds = linkWebhooks.map(({ linkId }) => linkId);
const links = await prisma.link.findMany({
where: {
id: { in: linkIds },
- projectId: workspace.id,
},
include: {
webhooks: {