set report date if status was changed
This commit is contained in:
@@ -188,6 +188,11 @@ export const report = {
|
||||
handler: async (input, context) => {
|
||||
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;
|
||||
if (input.status === 'closed') preReportStrike = await db.getStrikeByReportId({ reportId: input.reportId });
|
||||
|
||||
@@ -197,6 +202,7 @@ export const report = {
|
||||
if (input.strikeReasonId) {
|
||||
await db.editStrike({
|
||||
reportId: input.reportId,
|
||||
at: reportCreatedAt,
|
||||
strikeReasonId: input.strikeReasonId
|
||||
});
|
||||
} else {
|
||||
@@ -205,7 +211,6 @@ export const report = {
|
||||
});
|
||||
|
||||
if (input.status === 'closed' && preReportStrike?.strikeReason?.id != input.strikeReasonId) {
|
||||
const report = await db.getReportById({ id: input.reportId });
|
||||
if (report.reported) {
|
||||
const user = await db.getUserById({ id: report.reported.id });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user