Stop a saved Rule from taking uploads it does not own.
A named path no longer moves another Rules file. Duplicate and Make a copy write their own copies of files they keep.
This commit is contained in:
1 parent
9621fa4d7d
commit
94cee1dc5b
10 files changed
+757
-10
No files matched your search
@@ -9,6 +9,7 @@ import {
|
||||
} from "../../../../../lib/server/responses";
|
||||
import { getSessionUser } from "../../../../../lib/server/session";
|
||||
import { apiRoute } from "../../../../../lib/server/apiRoute";
|
||||
import { copyNamedUploadsForRule } from "../../../../../lib/server/uploads/copyNamedUploads";
|
||||
|
||||
type RouteContext = { params: Promise<{ id: string }> };
|
||||
|
||||
@@ -44,6 +45,12 @@ export const POST = apiRoute<RouteContext>(
|
||||
document: source.document,
|
||||
},
|
||||
});
|
||||
await copyNamedUploadsForRule({
|
||||
document: source.document,
|
||||
sourceRuleId: source.id,
|
||||
destRuleId: newRule.id,
|
||||
userId: user.id,
|
||||
});
|
||||
|
||||
return NextResponse.json({
|
||||
rule: {
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
findCopiedNameHit,
|
||||
stripCopiedRuleDocument,
|
||||
} from "../../../../../lib/create/copiedRuleDocument";
|
||||
import { copyNamedUploadsForRule } from "../../../../../lib/server/uploads/copyNamedUploads";
|
||||
|
||||
type RouteContext = { params: Promise<{ id: string }> };
|
||||
|
||||
@@ -88,13 +89,19 @@ export const POST = apiRoute<RouteContext>(
|
||||
document: documentParsed.data as Prisma.InputJsonValue,
|
||||
},
|
||||
});
|
||||
const document = await copyNamedUploadsForRule({
|
||||
document: documentParsed.data,
|
||||
sourceRuleId: stakeholder.rule.id,
|
||||
destRuleId: newRule.id,
|
||||
userId: user.id,
|
||||
});
|
||||
|
||||
return NextResponse.json({
|
||||
rule: {
|
||||
id: newRule.id,
|
||||
title: newRule.title,
|
||||
summary: newRule.summary,
|
||||
document: documentParsed.data,
|
||||
document,
|
||||
copiedFromTitle: stakeholder.rule.title,
|
||||
copiedNameHit,
|
||||
createdAt: newRule.createdAt,
|
||||
|
||||
Reference in new issue
Block a user