set report date if status was changed

This commit is contained in:
2025-12-27 15:28:33 +01:00
parent ec988ed545
commit d6409d4f96

View File

@@ -188,6 +188,11 @@ export const report = {
handler: async (input, context) => { handler: async (input, context) => {
Session.actionSessionFromCookies(context.cookies, Permissions.Reports); Session.actionSessionFromCookies(context.cookies, Permissions.Reports);
const report = await db.getReportById({ id: input.reportId });
let reportCreatedAt = undefined;
if (input.status !== null && report.createdAt === null) reportCreatedAt = new Date();
let preReportStrike; let preReportStrike;
if (input.status === 'closed') preReportStrike = await db.getStrikeByReportId({ reportId: input.reportId }); if (input.status === 'closed') preReportStrike = await db.getStrikeByReportId({ reportId: input.reportId });
@@ -197,6 +202,7 @@ export const report = {
if (input.strikeReasonId) { if (input.strikeReasonId) {
await db.editStrike({ await db.editStrike({
reportId: input.reportId, reportId: input.reportId,
at: reportCreatedAt,
strikeReasonId: input.strikeReasonId strikeReasonId: input.strikeReasonId
}); });
} else { } else {
@@ -205,7 +211,6 @@ export const report = {
}); });
if (input.status === 'closed' && preReportStrike?.strikeReason?.id != input.strikeReasonId) { if (input.status === 'closed' && preReportStrike?.strikeReason?.id != input.strikeReasonId) {
const report = await db.getReportById({ id: input.reportId });
if (report.reported) { if (report.reported) {
const user = await db.getUserById({ id: report.reported.id }); const user = await db.getUserById({ id: report.reported.id });