Start every Rule private, with a rotating link and files that follow its readers.
New Rules stay off lists until the person who holds the pen turns on a share link, or the team features one. Uploaded files are readable only by those readers, stripped of location metadata, and deleted with the Rule, draft, or account.
This commit is contained in:
1 parent
642551064c
commit
5cbda35e32
50 files changed
+2429
-219
No files matched your search
@@ -11,6 +11,8 @@ import { apiRoute } from "../../../../lib/server/apiRoute";
|
||||
import { putDraftBodySchema } from "../../../../lib/server/validation/createFlowSchemas";
|
||||
import { readLimitedJson } from "../../../../lib/server/validation/requestBody";
|
||||
import { jsonFromZodError } from "../../../../lib/server/validation/zodHttp";
|
||||
import { deleteUploadsForDraft } from "../../../../lib/server/uploads/deleteUploadedFiles";
|
||||
import { linkUploadsToDraft } from "../../../../lib/server/uploads/linkUploads";
|
||||
|
||||
export const GET = apiRoute("drafts.me.get", async () => {
|
||||
if (!isDatabaseConfigured()) {
|
||||
@@ -67,6 +69,11 @@ export const PUT = apiRoute("drafts.me.put", async (request: NextRequest) => {
|
||||
payload: jsonPayload,
|
||||
},
|
||||
});
|
||||
await linkUploadsToDraft({
|
||||
draftId: draft.id,
|
||||
payload,
|
||||
userId: user.id,
|
||||
});
|
||||
|
||||
return NextResponse.json({
|
||||
draft: { payload: draft.payload, updatedAt: draft.updatedAt },
|
||||
@@ -85,6 +92,13 @@ export const DELETE = apiRoute("drafts.me.delete", async () => {
|
||||
|
||||
// Idempotent: missing draft is a no-op so callers can fire-and-forget after
|
||||
// publish / exit without worrying about prior state.
|
||||
const draft = await prisma.ruleDraft.findUnique({
|
||||
where: { userId: user.id },
|
||||
select: { id: true },
|
||||
});
|
||||
if (draft) {
|
||||
await deleteUploadsForDraft(draft.id);
|
||||
}
|
||||
await prisma.ruleDraft.deleteMany({ where: { userId: user.id } });
|
||||
|
||||
return NextResponse.json({ ok: true });
|
||||
|
||||
Reference in new issue
Block a user