mirror of
https://github.com/hanzo-apps/dataroom.git
synced 2026-10-30 14:47:36 +00:00
Drop the dual-licensed `ee/` tree entirely. All features previously
locked behind the Hanzo Dataroom Commercial License are now part of the
AGPL-3.0 core and freely available — custom domains, branded viewing,
advanced analytics, watermarks, access controls, Q&A, AI vector stores,
workflows, SAML SSO, dataroom invitations, conversations, templates.
Layout changes:
* `ee/features/{ai,conversations,workflows,permissions,storage,templates,
dataroom-invitations,access-notifications,security,conversions}/` →
`features/<name>/` (AGPL).
* `ee/limits/` → `lib/billing/limits/` with every plan resolving to an
unlimited profile (no users/links/documents/domains/datarooms cap,
conversations and watermarks always on).
* `ee/stripe/` → `lib/billing/legacy/` (already a compat shim over
`@hanzoai/commerce`; renewal-reminder webhook is now a no-op).
* `ee/features/billing/cancellation/` deleted. Pause/unpause/cancel/
retention routes now compile against `lib/billing/cancellation.ts`
stubs that return 410 Gone; `isTeamPaused`/`isTeamPausedById` in
`lib/billing/paused.ts` always report active. `CancellationModal` is
a no-op shim in `components/billing/`.
* `app/(ee)/api/*` route group folded into `app/api/*` (SAML auth,
SCIM, AI chat, workflows, FAQ, link-upload).
Build: `npm run build` green.
100 lines
2.2 KiB
TypeScript
100 lines
2.2 KiB
TypeScript
import { isTeamPausedById } from "@/lib/billing/paused";
|
|
|
|
import prisma from "@/lib/prisma";
|
|
import { log } from "@/lib/utils";
|
|
import { sendWebhooks } from "@/lib/webhook/send-webhooks";
|
|
|
|
export async function sendDocumentCreatedWebhook({
|
|
teamId,
|
|
data,
|
|
}: {
|
|
teamId: string;
|
|
data: any;
|
|
}) {
|
|
try {
|
|
const { document_id: documentId } = data;
|
|
|
|
if (!documentId || !teamId) {
|
|
throw new Error("Missing required parameters");
|
|
}
|
|
|
|
// 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 is not on paid plan, so we don't need to send webhooks
|
|
return;
|
|
}
|
|
|
|
// check if team is paused
|
|
const teamIsPaused = await isTeamPausedById(teamId);
|
|
if (teamIsPaused) {
|
|
// team is paused, so we don't send webhooks
|
|
return;
|
|
}
|
|
|
|
// Get webhooks for team
|
|
const webhooks = await prisma.webhook.findMany({
|
|
where: {
|
|
teamId,
|
|
triggers: {
|
|
array_contains: ["document.created"],
|
|
},
|
|
},
|
|
select: {
|
|
pId: true,
|
|
url: true,
|
|
secret: true,
|
|
},
|
|
});
|
|
|
|
if (!webhooks || (webhooks && webhooks.length === 0)) {
|
|
// No webhooks for team, so we don't need to send webhooks
|
|
return;
|
|
}
|
|
|
|
// Get document information
|
|
const document = await prisma.document.findUnique({
|
|
where: { id: documentId, teamId },
|
|
});
|
|
|
|
if (!document) {
|
|
throw new Error("Document not found");
|
|
}
|
|
|
|
// Prepare document data for webhook
|
|
const documentData = {
|
|
id: document.id,
|
|
name: document.name,
|
|
contentType: document.contentType,
|
|
teamId: document.teamId,
|
|
createdAt: document.createdAt.toISOString(),
|
|
};
|
|
|
|
// Prepare webhook payload
|
|
const webhookData = {
|
|
document: documentData,
|
|
};
|
|
|
|
// Send webhooks
|
|
if (webhooks.length > 0) {
|
|
await sendWebhooks({
|
|
webhooks,
|
|
trigger: "document.created",
|
|
data: webhookData,
|
|
});
|
|
}
|
|
return;
|
|
} catch (error) {
|
|
log({
|
|
message: `Error sending webhooks for document created: ${error}`,
|
|
type: "error",
|
|
mention: true,
|
|
});
|
|
return;
|
|
}
|
|
}
|