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.

fix build

Kiran Ke7f02ba17be2
diff --git a/apps/web/app/api/slack/callback/route.ts b/apps/web/app/api/slack/callback/route.ts
index 8620e41389..f024d38050 100644
--- a/apps/web/app/api/slack/callback/route.ts
+++ b/apps/web/app/api/slack/callback/route.ts
@@ -75,13 +75,6 @@ export const GET = async (req: Request) => {
const data = await response.json();
- const webhook = await addWebhook({
- name: "Slack",
- url: data.incoming_webhook.url,
- triggers: ["link.created"],
- workspace,
- });
-
const credentials: SlackCredential = {
appId: data.app_id,
botUserId: data.bot_user_id,
diff --git a/apps/web/app/api/track/click/route.ts b/apps/web/app/api/track/click/route.ts
index 6e727c9d41..8e01090465 100644
--- a/apps/web/app/api/track/click/route.ts
+++ b/apps/web/app/api/track/click/route.ts
@@ -62,7 +62,7 @@ export const POST = async (req: Request) => {
linkId: link.id,
url: link.url,
skipRatelimit: true,
- workspaceId: workspace.id,
+ workspaceId: link.projectId,
}),
);
}
diff --git a/apps/web/app/api/webhooks/route.ts b/apps/web/app/api/webhooks/route.ts
index c0c826cae7..19c0ab48a8 100644
--- a/apps/web/app/api/webhooks/route.ts
+++ b/apps/web/app/api/webhooks/route.ts
@@ -5,7 +5,9 @@ import { prisma } from "@/lib/prisma";
import { createWebhook } from "@/lib/webhook/create-webhook";
import { transformWebhook } from "@/lib/webhook/transform";
import { updateWebhookStatusForWorkspace } from "@/lib/webhook/update-webhook";
+import { identifyWebhookReceiver } from "@/lib/webhook/utils";
import { createWebhookSchema } from "@/lib/zod/schemas/webhooks";
+import { WebhookReceiver } from "@prisma/client";
import { waitUntil } from "@vercel/functions";
import { sendEmail } from "emails";
import WebhookAdded from "emails/webhook-added";
@@ -96,9 +98,14 @@ export const POST = withWorkspace(
}
}
+ // Zapier use this endpoint to create webhooks from their app
+ const isZapierWebhook =
+ identifyWebhookReceiver(url) === WebhookReceiver.zapier;
+
const webhook = await createWebhook({
name,
url,
+ receiver: isZapierWebhook ? WebhookReceiver.zapier : WebhookReceiver.user,
triggers,
linkIds,
secret,
diff --git a/apps/web/lib/integrations/slack/uninstall.ts b/apps/web/lib/integrations/slack/uninstall.ts
index 549a012e9a..997aa81ae9 100644
--- a/apps/web/lib/integrations/slack/uninstall.ts
+++ b/apps/web/lib/integrations/slack/uninstall.ts
@@ -1,5 +1,4 @@
import { DubApiError } from "@/lib/api/errors";
-import { prisma } from "@/lib/prisma";
import { InstalledIntegration } from "@prisma/client";
import { getSlackEnv } from "./env";
import { SlackCredential } from "./type";
@@ -12,15 +11,6 @@ export const uninstallSlackIntegration = async ({
const env = getSlackEnv();
const credentials = installation.credentials as SlackCredential;
- // Remove the webhook added by the Slack integration
- if (credentials.incomingWebhook.webhookId) {
- await prisma.webhook.delete({
- where: {
- id: credentials.incomingWebhook.webhookId,
- },
- });
- }
-
const response = await fetch("https://slack.com/api/apps.uninstall", {
method: "POST",
headers: {
diff --git a/apps/web/lib/webhook/create-webhook.ts b/apps/web/lib/webhook/create-webhook.ts
index a3c6681099..80948911c9 100644
--- a/apps/web/lib/webhook/create-webhook.ts
+++ b/apps/web/lib/webhook/create-webhook.ts
@@ -21,7 +21,7 @@ export async function createWebhook({
installationId,
}: z.infer<typeof createWebhookSchema> & {
workspaceId: string;
- receiver?: WebhookReceiver;
+ receiver: WebhookReceiver;
installationId?: string;
}) {
const webhook = await prisma.webhook.create({