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.
131 lines
3.2 KiB
TypeScript
131 lines
3.2 KiB
TypeScript
import { NextApiRequest, NextApiResponse } from "next";
|
|
|
|
import { sendConversationNotification } from "@/features/conversations/emails/lib/send-conversation-notification";
|
|
|
|
import prisma from "@/lib/prisma";
|
|
import { log } from "@/lib/utils";
|
|
import { generateUnsubscribeUrl } from "@/lib/utils/unsubscribe";
|
|
|
|
export default async function handle(
|
|
req: NextApiRequest,
|
|
res: NextApiResponse,
|
|
) {
|
|
// We only allow POST requests
|
|
if (req.method !== "POST") {
|
|
res.status(405).json({ message: "Method Not Allowed" });
|
|
return;
|
|
}
|
|
|
|
// Extract the API Key from the Authorization header
|
|
const authHeader = req.headers.authorization;
|
|
const token = authHeader?.split(" ")[1]; // Assuming the format is "Bearer [token]"
|
|
|
|
// Check if the API Key matches
|
|
if (token !== process.env.INTERNAL_API_KEY) {
|
|
res.status(401).json({ message: "Unauthorized" });
|
|
return;
|
|
}
|
|
|
|
const {
|
|
linkUrl,
|
|
conversationId,
|
|
dataroomId,
|
|
viewerId,
|
|
senderUserId,
|
|
teamId,
|
|
} = req.body as {
|
|
linkUrl: string;
|
|
conversationId: string;
|
|
dataroomId: string;
|
|
viewerId: string;
|
|
senderUserId: string;
|
|
teamId: string;
|
|
};
|
|
|
|
let viewer: { email: string } | null = null;
|
|
|
|
try {
|
|
// Find the viewer
|
|
viewer = await prisma.viewer.findUnique({
|
|
where: {
|
|
id: viewerId,
|
|
teamId,
|
|
},
|
|
select: {
|
|
email: true,
|
|
},
|
|
});
|
|
|
|
if (!viewer) {
|
|
res.status(404).json({ message: "Viewer not found." });
|
|
return;
|
|
}
|
|
} catch (error) {
|
|
log({
|
|
message: `Failed to find viewer for viewerId: ${viewerId}. \n\n Error: ${error}`,
|
|
type: "error",
|
|
mention: true,
|
|
});
|
|
res.status(500).json({ message: (error as Error).message });
|
|
return;
|
|
}
|
|
|
|
// POST /api/jobs/send-conversation-new-message-notification
|
|
try {
|
|
// Fetch the conversation to verify the settings
|
|
const conversation = await prisma.conversation.findUnique({
|
|
where: {
|
|
id: conversationId,
|
|
dataroomId: dataroomId,
|
|
teamId: teamId,
|
|
},
|
|
select: {
|
|
title: true,
|
|
dataroom: {
|
|
select: {
|
|
name: true,
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
const user = await prisma.user.findUnique({
|
|
where: { id: senderUserId },
|
|
select: { email: true },
|
|
});
|
|
|
|
if (!user) {
|
|
res.status(404).json({ message: "Sender not found." });
|
|
return;
|
|
}
|
|
|
|
const unsubscribeUrl = generateUnsubscribeUrl({
|
|
viewerId,
|
|
dataroomId,
|
|
teamId,
|
|
});
|
|
|
|
await sendConversationNotification({
|
|
conversationTitle: conversation?.title || "",
|
|
dataroomName: conversation?.dataroom?.name || "",
|
|
senderEmail: user.email!,
|
|
to: viewer.email!,
|
|
url: linkUrl,
|
|
unsubscribeUrl,
|
|
});
|
|
|
|
res.status(200).json({
|
|
message: "Successfully sent dataroom change notification",
|
|
viewerId,
|
|
});
|
|
return;
|
|
} catch (error) {
|
|
log({
|
|
message: `Failed to send invite email for dataroom ${dataroomId} to viewer: ${viewerId}. \n\n Error: ${error} \n\n*Metadata*: \`{dataroomId: ${dataroomId}, viewerId: ${viewerId}}\``,
|
|
type: "error",
|
|
mention: true,
|
|
});
|
|
return res.status(500).json({ message: (error as Error).message });
|
|
}
|
|
}
|