feat : copy buzzy audit logs
This commit is contained in:
@@ -44,6 +44,7 @@ import {
|
||||
writeAuditLog,
|
||||
type AuditAction,
|
||||
type AuditActor,
|
||||
type AuditMetadata,
|
||||
} from "@/lib/audit-log";
|
||||
|
||||
const DEFAULT_SECTIONS = [
|
||||
@@ -77,6 +78,7 @@ async function auditGuide(
|
||||
action: AuditAction,
|
||||
guide: { id: string; name: string; characterKey: string; version: number },
|
||||
scope?: AdminEditorScope,
|
||||
metadata: AuditMetadata = {},
|
||||
) {
|
||||
await writeAuditLog(tx, context.actor, {
|
||||
action,
|
||||
@@ -88,6 +90,7 @@ async function auditGuide(
|
||||
guideName: guide.name,
|
||||
characterKey: guide.characterKey,
|
||||
...(context.overwrite ? { overwrite: true } : {}),
|
||||
...metadata,
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -484,7 +487,8 @@ export async function reorderExtraSections(
|
||||
const existing = await tx
|
||||
.select({ id: guideSections.id })
|
||||
.from(guideSections)
|
||||
.where(and(eq(guideSections.guideId, guideId), eq(guideSections.kind, "extra")));
|
||||
.where(and(eq(guideSections.guideId, guideId), eq(guideSections.kind, "extra")))
|
||||
.orderBy(asc(guideSections.sortOrder));
|
||||
const existingIds = new Set(existing.map((section) => section.id));
|
||||
if (
|
||||
existingIds.size !== data.sectionIds.length ||
|
||||
@@ -500,7 +504,9 @@ export async function reorderExtraSections(
|
||||
.set({ sortOrder: 4 + index })
|
||||
.where(eq(guideSections.id, sectionId));
|
||||
}
|
||||
await auditGuide(tx, context, "guide.extra.reordered", updated, "extras:list");
|
||||
await auditGuide(tx, context, "guide.extra.reordered", updated, "extras:list", {
|
||||
sectionIds: data.sectionIds,
|
||||
});
|
||||
return updated;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user