Skip to content

Commit 4afe019

Browse files
committed
Properly log distiction between refined/reversed
1 parent f97df30 commit 4afe019

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE "moderation_cases" ADD "reversed" BOOLEAN NOT NULL DEFAULT FALSE;

backend/src/plugin/moderation/helper/format.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,12 @@ function caseSummaryBase(type: ModEventType, target: string): string {
4747
export async function formatCaseDescription(info: CaseInfo, bigTitle: boolean): Promise<string> {
4848
let title = "Case #" + info.number;
4949

50-
if (info.shadowedBy !== null)
51-
title = `~~${title}~~ (refined or reversed by #${info.shadowedBy})`;
52-
else if (caseExpired(info))
50+
if (info.shadowedBy !== null) {
51+
if (info.reversed)
52+
title = `~~${title}~~ (reversed by #${info.shadowedBy})`;
53+
else
54+
title = `~~${title}~~ (refined by #${info.shadowedBy})`;
55+
} else if (caseExpired(info))
5356
title = `~~${title}~~ (expired)`;
5457

5558
if (bigTitle)

backend/src/plugin/moderation/storage/cases.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const CaseInfo = z.strictObject({
1010
createdAt: z.date(),
1111
expiresAt: z.date().nullable(),
1212
shadowedBy: z.number().nullable(),
13+
reversed: z.boolean(),
1314

1415
actorID: z.string(),
1516
targetID: z.string(),
@@ -155,7 +156,7 @@ export async function createCase(guildID: string, event: ModEvent): Promise<numb
155156

156157
const reverseType = reverseModEventType(event.type);
157158

158-
if (!(reverseType === null || reverseType === ModEventType.Warn || reverseType === ModEventType.Unwarn)) {
159+
if (reverseType !== null) {
159160
await client.query(
160161
`
161162
WITH "shadowed" AS (
@@ -170,7 +171,9 @@ export async function createCase(guildID: string, event: ModEvent): Promise<numb
170171
LIMIT 1
171172
)
172173
UPDATE "moderation_cases"
173-
SET "shadowedBy" = $1
174+
SET
175+
"shadowedBy" = $1,
176+
"reversed" = ("type" = $4)
174177
FROM "shadowed"
175178
WHERE
176179
"moderation_cases"."guildID" = "shadowed"."guildID"

0 commit comments

Comments
 (0)