From a2c1ea98b3d8ac257b0913bda997c05267964d65 Mon Sep 17 00:00:00 2001 From: bytedream Date: Sat, 3 Jan 2026 20:05:19 +0100 Subject: [PATCH] update admin report editing --- src/actions/report.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/actions/report.ts b/src/actions/report.ts index a33c21a..4f89ed0 100644 --- a/src/actions/report.ts +++ b/src/actions/report.ts @@ -189,29 +189,29 @@ export const report = { Session.actionSessionFromCookies(context.cookies, Permissions.Reports); const report = await db.getReportById({ id: input.reportId }); + const strike = await db.getStrikeByReportId({ reportId: input.reportId }); let reportCreatedAt = undefined; if (input.status !== null && report.createdAt === null) reportCreatedAt = new Date(); - let preReportStrike; - if (input.status === 'closed') preReportStrike = await db.getStrikeByReportId({ reportId: input.reportId }); - await db.transaction(async (tx) => { if (reportCreatedAt) await tx.editReport({ id: input.reportId, createdAt: reportCreatedAt }); await tx.editReportStatus(input); - if (input.strikeReasonId) { - await db.editStrike({ - reportId: input.reportId, - strikeReasonId: input.strikeReasonId - }); - } else { - await db.deleteStrike({ reportId: input.reportId }); + if (strike?.strikeReason?.id != input.strikeReasonId) { + if (input.strikeReasonId) { + await db.editStrike({ + reportId: input.reportId, + strikeReasonId: input.strikeReasonId + }); + } else { + await db.deleteStrike({ reportId: input.reportId }); + } } }); - if (input.status === 'closed' && preReportStrike?.strikeReason?.id != input.strikeReasonId) { + if (input.status === 'closed' && strike?.strikeReason?.id != input.strikeReasonId) { if (report.reported) { const user = await db.getUserById({ id: report.reported.id });