update admin report editing
All checks were successful
deploy / build-and-deploy (push) Successful in 20s
All checks were successful
deploy / build-and-deploy (push) Successful in 20s
This commit is contained in:
@@ -189,18 +189,17 @@ 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 (strike?.strikeReason?.id != input.strikeReasonId) {
|
||||
if (input.strikeReasonId) {
|
||||
await db.editStrike({
|
||||
reportId: input.reportId,
|
||||
@@ -209,9 +208,10 @@ export const report = {
|
||||
} 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 });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user