Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
Added changes to disable the Papermark assistant
Vinod Pal0a6ab334d66b
diff --git a/pages/api/assistants/index.ts b/pages/api/assistants/index.tsindex b851a606..8512375a 100644--- a/pages/api/assistants/index.ts+++ b/pages/api/assistants/index.ts@@ -75,9 +75,74 @@ export default async function handle(} catch (error) {errorhandler(error, res);}+ } else if (req.method === "DELETE") {+ // DELETE /api/assistants+ const session = await getServerSession(req, res, authOptions);+ if (!session) {+ return res.status(401).end("Unauthorized");+ }++ const { documentId } = req.body as { documentId: string };++ try {+ const document = await prisma.document.findUnique({+ where: {+ id: documentId,+ },+ select: {+ assistantEnabled: true,+ versions: {+ where: { isPrimary: true },+ take: 1,+ select: {+ id: true,+ fileId: true,+ file: true,+ },+ },+ },+ });++ if (!document) {+ res.status(400).json("No document found");+ return;+ }++ if (!document.assistantEnabled) {+ res.status(200).json("Assistant is already disabled");+ return;+ }++ // Upload the file to OpenAI+ const fileId = document.versions[0].fileId;++ if (fileId) {+ await openai.files.del(fileId);+ }++ // Update the document and documentVersion in the database+ await prisma.documentVersion.update({+ where: {+ id: document.versions[0].id,+ },+ data: {+ fileId: null,+ document: {+ update: {+ assistantEnabled: false,+ },+ },+ },+ });++ res.status(200).json("Assistant Disabled");+ return;+ } catch (error) {+ errorhandler(error, res);+ }} else {- // We only allow GET and DELETE requests- res.setHeader("Allow", ["POST"]);+ // We only allow POST and DELETE requests+ res.setHeader("Allow", ["POST", "DELETE"]);return res.status(405).end(`Method ${req.method} Not Allowed`);}}diff --git a/pages/documents/[id]/index.tsx b/pages/documents/[id]/index.tsxindex 02cdb351..722d3761 100644--- a/pages/documents/[id]/index.tsx+++ b/pages/documents/[id]/index.tsx@@ -293,10 +293,10 @@ export default function DocumentPage() {});toast.promise(fetchPromise, {- loading: "Activating Assistant...",+ loading: "Deactivating Assistant...",success:- "Papermark Assistant successfully activated.",- error: "Activation failed. Please try again.",+ "Papermark Assistant successfully de-activated.",+ error: "De-activation failed. Please try again.",});}}>