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
@@ -0,0 +1,44 @@
|
||||
import { logger } from "../../logger";
|
||||
import { prisma } from "../db";
|
||||
import { extractUploadIdsFromUnknown } from "./extractUploadIds";
|
||||
|
||||
export async function linkUploadsToRule(opts: {
|
||||
ruleId: string;
|
||||
document: unknown;
|
||||
userId: string | null;
|
||||
}): Promise<void> {
|
||||
const ids = extractUploadIdsFromUnknown(opts.document);
|
||||
if (ids.length === 0) return;
|
||||
try {
|
||||
await prisma.upload.updateMany({
|
||||
where: { id: { in: ids } },
|
||||
data: {
|
||||
ruleId: opts.ruleId,
|
||||
draftId: null,
|
||||
...(opts.userId ? { userId: opts.userId } : {}),
|
||||
},
|
||||
});
|
||||
} catch (err) {
|
||||
logger.warn("[uploads] failed to link uploads to rule", opts.ruleId, err);
|
||||
}
|
||||
}
|
||||
|
||||
export async function linkUploadsToDraft(opts: {
|
||||
draftId: string;
|
||||
payload: unknown;
|
||||
userId: string;
|
||||
}): Promise<void> {
|
||||
const ids = extractUploadIdsFromUnknown(opts.payload);
|
||||
if (ids.length === 0) return;
|
||||
try {
|
||||
await prisma.upload.updateMany({
|
||||
where: { id: { in: ids }, ruleId: null },
|
||||
data: {
|
||||
draftId: opts.draftId,
|
||||
userId: opts.userId,
|
||||
},
|
||||
});
|
||||
} catch (err) {
|
||||
logger.warn("[uploads] failed to link uploads to draft", opts.draftId, err);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user