feat : copy buzzy audit logs
This commit is contained in:
+10
-1
@@ -691,6 +691,7 @@ export async function cancelCatalogSyncJob(
|
||||
action: "catalog_sync.cancel_requested",
|
||||
targetType: "catalog_sync",
|
||||
targetId: id,
|
||||
metadata: { status: job.status },
|
||||
});
|
||||
return writeSyncJob({ ...job, message: "กำลังยกเลิก Sync…", status: "cancelled" });
|
||||
}
|
||||
@@ -701,6 +702,7 @@ export async function startCatalogSyncJob(actor: AuditActor): Promise<CatalogSyn
|
||||
action: "catalog_sync.requested",
|
||||
targetType: "catalog_sync",
|
||||
targetId: id,
|
||||
metadata: { status: "queued" },
|
||||
});
|
||||
const job = await writeSyncJob({ id, status: "queued", phase: "queued", completed: 0, total: 0, message: "กำลังเตรียม Sync" });
|
||||
void executeCatalogSyncJob(job, actor).catch(() => undefined);
|
||||
@@ -738,6 +740,9 @@ async function executeCatalogSyncJob(initial: CatalogSyncJob, actor: AuditActor)
|
||||
: "catalog_sync.completed",
|
||||
targetType: "catalog_sync",
|
||||
targetId: initial.id,
|
||||
metadata: {
|
||||
status: result === "unchanged" ? "unchanged" : "completed",
|
||||
},
|
||||
});
|
||||
} catch (cause) {
|
||||
if (cause instanceof Error && cause.message === "CATALOG_SYNC_CANCELLED") {
|
||||
@@ -746,6 +751,7 @@ async function executeCatalogSyncJob(initial: CatalogSyncJob, actor: AuditActor)
|
||||
action: "catalog_sync.cancelled",
|
||||
targetType: "catalog_sync",
|
||||
targetId: initial.id,
|
||||
metadata: { status: "cancelled" },
|
||||
});
|
||||
} else {
|
||||
const error = cause instanceof Error ? cause.message : "Unknown sync error";
|
||||
@@ -754,7 +760,10 @@ async function executeCatalogSyncJob(initial: CatalogSyncJob, actor: AuditActor)
|
||||
action: "catalog_sync.failed",
|
||||
targetType: "catalog_sync",
|
||||
targetId: initial.id,
|
||||
metadata: { error: error.slice(0, 500) },
|
||||
metadata: {
|
||||
error: error.slice(0, 500),
|
||||
status: "error",
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user