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.
72 lines
2.0 KiB
TypeScript
72 lines
2.0 KiB
TypeScript
import { NextApiResponse } from "next";
|
|
|
|
import { FREE_PLAN_LIMITS } from "@/lib/billing/limits/constants";
|
|
import { Prisma } from "@prisma/client";
|
|
import type { CommerceTypes } from "@/lib/commerce";
|
|
|
|
import { clearTeamDomainRedirects } from "@/lib/api/domains/clear-team-redirects";
|
|
import prisma from "@/lib/prisma";
|
|
import { log } from "@/lib/utils";
|
|
|
|
export async function customerSubscriptionDeleted(
|
|
event: CommerceTypes.Event,
|
|
res: NextApiResponse,
|
|
) {
|
|
const subscriptionDeleted = event.data.object as CommerceTypes.Subscription;
|
|
|
|
const stripeId = subscriptionDeleted.customer.toString();
|
|
const subscriptionId = subscriptionDeleted.id;
|
|
|
|
// get free plan limits
|
|
const freePlanLimits = structuredClone(FREE_PLAN_LIMITS);
|
|
|
|
try {
|
|
// If a team cancels their subscription, reset their limits to free
|
|
const team = await prisma.team.update({
|
|
where: {
|
|
stripeId,
|
|
subscriptionId,
|
|
},
|
|
data: {
|
|
plan: "free",
|
|
subscriptionId: null,
|
|
endsAt: null,
|
|
startsAt: null,
|
|
limits: freePlanLimits,
|
|
cancelledAt: null,
|
|
pausedAt: null,
|
|
pauseStartsAt: null,
|
|
pauseEndsAt: null,
|
|
},
|
|
select: { id: true },
|
|
});
|
|
|
|
await clearTeamDomainRedirects(team.id);
|
|
|
|
await log({
|
|
message: ":cry: Team *`" + team.id + "`* deleted their subscription",
|
|
type: "info",
|
|
});
|
|
} catch (error) {
|
|
if (
|
|
error instanceof Prisma.PrismaClientKnownRequestError &&
|
|
error.code === "P2025"
|
|
) {
|
|
await log({
|
|
message: `Team with Stripe ID ${stripeId} and Subscription ID ${subscriptionId} not found`,
|
|
type: "error",
|
|
});
|
|
return res
|
|
.status(200)
|
|
.send("Team not found in database. Customer deleted their account.");
|
|
}
|
|
await log({
|
|
message: `Error updating team ${stripeId} subscription ${subscriptionId}: ${error}`,
|
|
type: "error",
|
|
});
|
|
return res
|
|
.status(200)
|
|
.send("Error processing subscription deletion webhook.");
|
|
}
|
|
}
|