Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

fix: add missing feature flag

Marc Seitz2c2cf8aafa69
diff --git a/pages/api/teams/[teamId]/documents/[id]/index.ts b/pages/api/teams/[teamId]/documents/[id]/index.ts
index aa79054a..da9dcfb7 100644
--- a/pages/api/teams/[teamId]/documents/[id]/index.ts
+++ b/pages/api/teams/[teamId]/documents/[id]/index.ts
@@ -1,16 +1,16 @@
import { NextApiRequest, NextApiResponse } from "next";
+import { authOptions } from "@/pages/api/auth/[...nextauth]";
import { getServerSession } from "next-auth/next";
import { TeamError, errorhandler } from "@/lib/errorHandler";
+import { getFeatureFlags } from "@/lib/featureFlags";
import { deleteFile } from "@/lib/files/delete-file-server";
import prisma from "@/lib/prisma";
import { ratelimit } from "@/lib/redis";
import { CustomUser } from "@/lib/types";
import { serializeFileSize } from "@/lib/utils";
-import { authOptions } from "../../../../auth/[...nextauth]";
-
export default async function handle(
req: NextApiRequest,
res: NextApiResponse,
@@ -214,6 +214,15 @@ export default async function handle(
agentsEnabled?: boolean;
};
+ if (agentsEnabled !== undefined) {
+ const features = await getFeatureFlags({ teamId });
+ if (!features.ai) {
+ return res
+ .status(403)
+ .json({ message: "AI feature is not available" });
+ }
+ }
+
// Build update data object with only provided fields
const updateData: { agentsEnabled?: boolean } = {};