Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
fix: check if team can send webhooks
Marc Seitz214d3c3eb05e
diff --git a/lib/api/views/send-webhook-event.ts b/lib/api/views/send-webhook-event.tsindex c446513b..e5c1f984 100644--- a/lib/api/views/send-webhook-event.ts+++ b/lib/api/views/send-webhook-event.ts@@ -1,4 +1,3 @@-import { getFeatureFlags } from "@/lib/featureFlags";import prisma from "@/lib/prisma";import { log } from "@/lib/utils";import { sendWebhooks } from "@/lib/webhook/send-webhooks";@@ -22,9 +21,18 @@ export async function sendLinkViewWebhook({throw new Error("Missing required parameters");}- const features = await getFeatureFlags({ teamId });- if (!features.webhooks) {- // webhooks are not enabled for this team+ // check if team is on paid plan+ const team = await prisma.team.findUnique({+ where: { id: teamId },+ select: { plan: true },+ });++ if (+ team?.plan === "free" ||+ team?.plan === "pro" ||+ team?.plan.includes("trial")+ ) {+ // team is not on paid plan, so we don't need to send webhooksreturn;}diff --git a/lib/webhook/triggers/document-created.ts b/lib/webhook/triggers/document-created.tsindex d85abdab..380742ec 100644--- a/lib/webhook/triggers/document-created.ts+++ b/lib/webhook/triggers/document-created.ts@@ -1,4 +1,3 @@-import { getFeatureFlags } from "@/lib/featureFlags";import prisma from "@/lib/prisma";import { log } from "@/lib/utils";import { sendWebhooks } from "@/lib/webhook/send-webhooks";@@ -17,9 +16,18 @@ export async function sendDocumentCreatedWebhook({throw new Error("Missing required parameters");}- const features = await getFeatureFlags({ teamId });- if (!features.webhooks) {- // webhooks are not enabled for this team+ // check if team is on paid plan+ const team = await prisma.team.findUnique({+ where: { id: teamId },+ select: { plan: true },+ });++ if (+ team?.plan === "free" ||+ team?.plan === "pro" ||+ team?.plan.includes("trial")+ ) {+ // team is not on paid plan, so we don't need to send webhooksreturn;}diff --git a/lib/webhook/triggers/link-created.ts b/lib/webhook/triggers/link-created.tsindex aefd4ab7..3f7c9de6 100644--- a/lib/webhook/triggers/link-created.ts+++ b/lib/webhook/triggers/link-created.ts@@ -1,4 +1,3 @@-import { getFeatureFlags } from "@/lib/featureFlags";import prisma from "@/lib/prisma";import { log } from "@/lib/utils";import { sendWebhooks } from "@/lib/webhook/send-webhooks";@@ -21,9 +20,18 @@ export async function sendLinkCreatedWebhook({throw new Error("Missing required parameters");}- const features = await getFeatureFlags({ teamId });- if (!features.webhooks) {- // webhooks are not enabled for this team+ // check if team is on paid plan+ const team = await prisma.team.findUnique({+ where: { id: teamId },+ select: { plan: true },+ });++ if (+ team?.plan === "free" ||+ team?.plan === "pro" ||+ team?.plan.includes("trial")+ ) {+ // team is not on paid plan, so we don't need to send webhooksreturn;}