@chatwarden/core 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +306 -7
- package/dist/src/ai/case.d.ts +4 -3
- package/dist/src/ai/case.d.ts.map +1 -1
- package/dist/src/ai/case.js +1 -1
- package/dist/src/ai/case.js.map +1 -1
- package/dist/src/ai/hash.d.ts +3 -1
- package/dist/src/ai/hash.d.ts.map +1 -1
- package/dist/src/ai/hash.js +5 -2
- package/dist/src/ai/hash.js.map +1 -1
- package/dist/src/ai/prompt.d.ts +13 -2
- package/dist/src/ai/prompt.d.ts.map +1 -1
- package/dist/src/ai/prompt.js +31 -1
- package/dist/src/ai/prompt.js.map +1 -1
- package/dist/src/ai/service.d.ts +21 -6
- package/dist/src/ai/service.d.ts.map +1 -1
- package/dist/src/ai/service.js +14 -7
- package/dist/src/ai/service.js.map +1 -1
- package/dist/src/ai/types.d.ts +33 -2
- package/dist/src/ai/types.d.ts.map +1 -1
- package/dist/src/ai/types.js +3 -2
- package/dist/src/ai/types.js.map +1 -1
- package/dist/src/ai/worker.d.ts +8 -1
- package/dist/src/ai/worker.d.ts.map +1 -1
- package/dist/src/ai/worker.js +17 -3
- package/dist/src/ai/worker.js.map +1 -1
- package/dist/src/appealService.d.ts +105 -0
- package/dist/src/appealService.d.ts.map +1 -0
- package/dist/src/appealService.js +548 -0
- package/dist/src/appealService.js.map +1 -0
- package/dist/src/appeals.d.ts +194 -0
- package/dist/src/appeals.d.ts.map +1 -0
- package/dist/src/appeals.js +107 -0
- package/dist/src/appeals.js.map +1 -0
- package/dist/src/audit.d.ts +7 -3
- package/dist/src/audit.d.ts.map +1 -1
- package/dist/src/audit.js +18 -3
- package/dist/src/audit.js.map +1 -1
- package/dist/src/chat.d.ts +39 -1
- package/dist/src/chat.d.ts.map +1 -1
- package/dist/src/chat.js +85 -6
- package/dist/src/chat.js.map +1 -1
- package/dist/src/chatwarden.d.ts +197 -10
- package/dist/src/chatwarden.d.ts.map +1 -1
- package/dist/src/chatwarden.js +212 -23
- package/dist/src/chatwarden.js.map +1 -1
- package/dist/src/decide.d.ts +2 -0
- package/dist/src/decide.d.ts.map +1 -1
- package/dist/src/decide.js +12 -7
- package/dist/src/decide.js.map +1 -1
- package/dist/src/documents.d.ts +1 -1
- package/dist/src/documents.d.ts.map +1 -1
- package/dist/src/documents.js +5 -1
- package/dist/src/documents.js.map +1 -1
- package/dist/src/events.d.ts +38 -0
- package/dist/src/events.d.ts.map +1 -1
- package/dist/src/events.js +3 -0
- package/dist/src/events.js.map +1 -1
- package/dist/src/freeze.d.ts +3 -0
- package/dist/src/freeze.d.ts.map +1 -0
- package/dist/src/freeze.js +10 -0
- package/dist/src/freeze.js.map +1 -0
- package/dist/src/index.d.ts +20 -9
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +11 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/ladder.d.ts +28 -0
- package/dist/src/ladder.d.ts.map +1 -1
- package/dist/src/ladder.js +37 -1
- package/dist/src/ladder.js.map +1 -1
- package/dist/src/nameService.d.ts +90 -0
- package/dist/src/nameService.d.ts.map +1 -0
- package/dist/src/nameService.js +224 -0
- package/dist/src/nameService.js.map +1 -0
- package/dist/src/names.d.ts +68 -0
- package/dist/src/names.d.ts.map +1 -0
- package/dist/src/names.js +87 -0
- package/dist/src/names.js.map +1 -0
- package/dist/src/notices.d.ts +53 -5
- package/dist/src/notices.d.ts.map +1 -1
- package/dist/src/notices.js +93 -8
- package/dist/src/notices.js.map +1 -1
- package/dist/src/pace.d.ts +66 -0
- package/dist/src/pace.d.ts.map +1 -0
- package/dist/src/pace.js +111 -0
- package/dist/src/pace.js.map +1 -0
- package/dist/src/pacing.d.ts +63 -0
- package/dist/src/pacing.d.ts.map +1 -0
- package/dist/src/pacing.js +198 -0
- package/dist/src/pacing.js.map +1 -0
- package/dist/src/policy.d.ts +66 -1
- package/dist/src/policy.d.ts.map +1 -1
- package/dist/src/policy.js +86 -5
- package/dist/src/policy.js.map +1 -1
- package/dist/src/profile.d.ts +57 -8
- package/dist/src/profile.d.ts.map +1 -1
- package/dist/src/profile.js +69 -25
- package/dist/src/profile.js.map +1 -1
- package/dist/src/profileError.d.ts +10 -0
- package/dist/src/profileError.d.ts.map +1 -0
- package/dist/src/profileError.js +17 -0
- package/dist/src/profileError.js.map +1 -0
- package/dist/src/retention.d.ts +40 -1
- package/dist/src/retention.d.ts.map +1 -1
- package/dist/src/retention.js +50 -3
- package/dist/src/retention.js.map +1 -1
- package/dist/src/sanctions.d.ts +29 -1
- package/dist/src/sanctions.d.ts.map +1 -1
- package/dist/src/sanctions.js +52 -9
- package/dist/src/sanctions.js.map +1 -1
- package/dist/src/signalCounts.d.ts +37 -0
- package/dist/src/signalCounts.d.ts.map +1 -0
- package/dist/src/signalCounts.js +117 -0
- package/dist/src/signalCounts.js.map +1 -0
- package/dist/src/signalInert.d.ts +10 -0
- package/dist/src/signalInert.d.ts.map +1 -0
- package/dist/src/signalInert.js +28 -0
- package/dist/src/signalInert.js.map +1 -0
- package/dist/src/signalService.d.ts +101 -0
- package/dist/src/signalService.d.ts.map +1 -0
- package/dist/src/signalService.js +383 -0
- package/dist/src/signalService.js.map +1 -0
- package/dist/src/signals.d.ts +186 -0
- package/dist/src/signals.d.ts.map +1 -0
- package/dist/src/signals.js +361 -0
- package/dist/src/signals.js.map +1 -0
- package/dist/src/staffViews.d.ts +18 -0
- package/dist/src/staffViews.d.ts.map +1 -1
- package/dist/src/staffViews.js +14 -0
- package/dist/src/staffViews.js.map +1 -1
- package/dist/src/subjects.d.ts +2 -0
- package/dist/src/subjects.d.ts.map +1 -1
- package/dist/src/subjects.js +4 -0
- package/dist/src/subjects.js.map +1 -1
- package/dist/src/team.d.ts +27 -0
- package/dist/src/team.d.ts.map +1 -1
- package/dist/src/team.js +92 -4
- package/dist/src/team.js.map +1 -1
- package/dist/src/types.d.ts +254 -7
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js.map +1 -1
- package/package.json +2 -2
- package/src/ai/case.ts +6 -4
- package/src/ai/hash.ts +5 -2
- package/src/ai/prompt.ts +39 -2
- package/src/ai/service.ts +29 -14
- package/src/ai/types.ts +31 -2
- package/src/ai/worker.ts +20 -4
- package/src/appealService.ts +584 -0
- package/src/appeals.ts +256 -0
- package/src/audit.ts +18 -3
- package/src/chat.ts +109 -8
- package/src/chatwarden.ts +382 -27
- package/src/decide.ts +13 -7
- package/src/documents.ts +8 -3
- package/src/events.ts +23 -1
- package/src/freeze.ts +8 -0
- package/src/index.ts +52 -3
- package/src/ladder.ts +59 -1
- package/src/nameService.ts +255 -0
- package/src/names.ts +121 -0
- package/src/notices.ts +112 -14
- package/src/pace.ts +139 -0
- package/src/pacing.ts +242 -0
- package/src/policy.ts +125 -8
- package/src/profile.ts +115 -25
- package/src/profileError.ts +17 -0
- package/src/retention.ts +79 -3
- package/src/sanctions.ts +72 -9
- package/src/signalCounts.ts +133 -0
- package/src/signalInert.ts +31 -0
- package/src/signalService.ts +406 -0
- package/src/signals.ts +489 -0
- package/src/staffViews.ts +30 -0
- package/src/subjects.ts +5 -0
- package/src/team.ts +93 -5
- package/src/types.ts +275 -8
|
@@ -0,0 +1,584 @@
|
|
|
1
|
+
import {
|
|
2
|
+
APPEAL_OUTCOMES,
|
|
3
|
+
APPEAL_RATE_ELEVATED,
|
|
4
|
+
APPEAL_RATE_HIGH,
|
|
5
|
+
APPEAL_STATEMENT_MAX,
|
|
6
|
+
APPEAL_STATS_MIN_SANCTIONS,
|
|
7
|
+
normalizeStatement,
|
|
8
|
+
SANCTION_KIND_ORDER,
|
|
9
|
+
statementLength,
|
|
10
|
+
} from './appeals.js';
|
|
11
|
+
import type {
|
|
12
|
+
AppealDecideResult,
|
|
13
|
+
AppealDecision,
|
|
14
|
+
AppealDetail,
|
|
15
|
+
AppealFileResult,
|
|
16
|
+
AppealOutcome,
|
|
17
|
+
AppealPage,
|
|
18
|
+
AppealRuleStats,
|
|
19
|
+
AppealStats,
|
|
20
|
+
AppealSummary,
|
|
21
|
+
PlayerAppeal,
|
|
22
|
+
ResolvedAppeals,
|
|
23
|
+
} from './appeals.js';
|
|
24
|
+
import { isValidAuditActor } from './audit.js';
|
|
25
|
+
import { randomId } from './crypto.js';
|
|
26
|
+
import type { KitEvent } from './events.js';
|
|
27
|
+
import { safeWarn } from './log.js';
|
|
28
|
+
import { appliesInRecord } from './notices.js';
|
|
29
|
+
import type { NoticeService } from './notices.js';
|
|
30
|
+
import { parseRuleRef } from './rules.js';
|
|
31
|
+
import type { RuleRef } from './rules.js';
|
|
32
|
+
import { APPEALS_START_TOKEN, MAX_SANCTION_DURATION_MS, writeSanction } from './sanctions.js';
|
|
33
|
+
import type { SanctionIndex } from './sanctions.js';
|
|
34
|
+
import { b64urlDecode, b64urlEncode } from './staffReports.js';
|
|
35
|
+
import type { SubjectIndex } from './subjects.js';
|
|
36
|
+
import type { AppealRow, Clock, Logger, Matcher, RawWho, SanctionRow, Store, SubjectId } from './types.js';
|
|
37
|
+
|
|
38
|
+
// The appeals service: filing (the player side) here; deciding and the staff reads are added to the same class. It holds no state of its own:
|
|
39
|
+
// every fact is in the store, so two processes on one database agree.
|
|
40
|
+
|
|
41
|
+
const WEEK_MS = 7 * 24 * 3_600_000;
|
|
42
|
+
/** The most appeals `mine` answers. */
|
|
43
|
+
export const MINE_MAX = 50;
|
|
44
|
+
|
|
45
|
+
/** The store methods appeals need. A store without all of them cannot keep appeals. */
|
|
46
|
+
export const APPEAL_STORE_METHODS = [
|
|
47
|
+
'insertAppeal',
|
|
48
|
+
'loadAppeal',
|
|
49
|
+
'listAppeals',
|
|
50
|
+
'listAppealsBy',
|
|
51
|
+
'countAppealsBy',
|
|
52
|
+
'countOpenAppeals',
|
|
53
|
+
'decideAppeal',
|
|
54
|
+
'closeAppealsForGroup',
|
|
55
|
+
'appealCountsByRule',
|
|
56
|
+
'countSanctionsByRule',
|
|
57
|
+
'loadSanctionSubjectRow',
|
|
58
|
+
] as const;
|
|
59
|
+
|
|
60
|
+
/** True when the store has every method appeals need. */
|
|
61
|
+
export function hasAppealMethods(store: Store): boolean {
|
|
62
|
+
const s = store as unknown as Record<string, unknown>;
|
|
63
|
+
return APPEAL_STORE_METHODS.every((m) => typeof s[m] === 'function');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface AppealServiceDeps {
|
|
67
|
+
store: Store;
|
|
68
|
+
subjects: SubjectIndex;
|
|
69
|
+
notices: NoticeService;
|
|
70
|
+
clock: Clock;
|
|
71
|
+
logger?: Logger | undefined;
|
|
72
|
+
/** The appeal settings in force, read live. */
|
|
73
|
+
settings: () => ResolvedAppeals;
|
|
74
|
+
/** The person behind a player's connection details, FOUND and never created. */
|
|
75
|
+
personOf: (who: RawWho) => SubjectId | null;
|
|
76
|
+
/** Announce an event after a commit. Fenced by the caller of the service. */
|
|
77
|
+
emit: (event: KitEvent) => void;
|
|
78
|
+
/** The term matcher, to say whether a statement trips it (read on every list and get, so a term added later masks an older statement). */
|
|
79
|
+
matcher?: Matcher | undefined;
|
|
80
|
+
/** The in-memory sanction index: a revoked or replaced group leaves it, a replacement joins it, after the commit. */
|
|
81
|
+
index: SanctionIndex;
|
|
82
|
+
/** True when `retention.appealStatementsMs` is 0: a statement is cleared in the decision (and as an appeal is made moot). */
|
|
83
|
+
clearStatements: () => boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Told, inside the decision's transaction and fenced, when an appeal was granted (`reduce` or `revoke`) and its sanction came from a
|
|
86
|
+
* report: the AI's casebook marks that decision reversed. A throw is logged and never fails the decision.
|
|
87
|
+
*/
|
|
88
|
+
onGranted?: (appeal: AppealRow, outcome: 'reduce' | 'revoke') => void;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** A decision step that must roll the transaction back and answer something other than success. */
|
|
92
|
+
class Stop extends Error {
|
|
93
|
+
readonly why: 'already_decided' | 'gone';
|
|
94
|
+
constructor(why: 'already_decided' | 'gone') {
|
|
95
|
+
super(why);
|
|
96
|
+
this.why = why;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const OUTCOME_STATUS = { uphold: 'upheld', reduce: 'reduced', revoke: 'revoked' } as const;
|
|
101
|
+
const OUTCOME_NOTICE = { uphold: 'appeal_upheld', reduce: 'appeal_reduced', revoke: 'appeal_revoked' } as const;
|
|
102
|
+
const INVALID = { ok: false, error: 'invalid' } as const;
|
|
103
|
+
|
|
104
|
+
interface CheckedDecision {
|
|
105
|
+
appealId: string;
|
|
106
|
+
outcome: AppealOutcome;
|
|
107
|
+
actor: string;
|
|
108
|
+
reason: string;
|
|
109
|
+
to: { kind: 'warning' | 'chat' | 'area' | 'ban'; durationMs: number | null } | null;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** The decision as the service reads it, or null when it is not well formed. Each field is read once. */
|
|
113
|
+
function checkDecision(input: AppealDecision): CheckedDecision | null {
|
|
114
|
+
if (typeof input !== 'object' || input === null) return null;
|
|
115
|
+
const { appealId, outcome, actor, reason, to } = input as unknown as Record<string, unknown>;
|
|
116
|
+
if (typeof appealId !== 'string' || appealId === '') return null;
|
|
117
|
+
if (typeof outcome !== 'string' || !(APPEAL_OUTCOMES as readonly string[]).includes(outcome)) return null;
|
|
118
|
+
if (!isValidAuditActor(actor)) return null;
|
|
119
|
+
const why = typeof reason === 'string' ? reason.trim() : '';
|
|
120
|
+
if (why === '' || why.length > 500) return null;
|
|
121
|
+
if (outcome !== 'reduce') return to === undefined ? { appealId, outcome: outcome as AppealOutcome, actor, reason: why, to: null } : null;
|
|
122
|
+
if (typeof to !== 'object' || to === null) return null;
|
|
123
|
+
const { kind, durationMs } = to as Record<string, unknown>;
|
|
124
|
+
if (typeof kind !== 'string' || !(SANCTION_KIND_ORDER as readonly string[]).includes(kind)) return null;
|
|
125
|
+
if (kind === 'warning') {
|
|
126
|
+
if (durationMs !== null) return null;
|
|
127
|
+
} else if (durationMs !== null && (typeof durationMs !== 'number' || !Number.isSafeInteger(durationMs) || durationMs <= 0 || durationMs > MAX_SANCTION_DURATION_MS)) {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
return { appealId, outcome: 'reduce', actor, reason: why, to: { kind: kind as 'warning' | 'chat' | 'area' | 'ban', durationMs: durationMs as number | null } };
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** A refusal that must roll the filing's transaction back (the row was written to test the unique group and the rate). */
|
|
134
|
+
class Refuse extends Error {
|
|
135
|
+
readonly refused: 'already_appealed' | 'rate' | 'not_appealable';
|
|
136
|
+
readonly retryAfterMs: number | undefined;
|
|
137
|
+
constructor(refused: 'already_appealed' | 'rate' | 'not_appealable', retryAfterMs?: number) {
|
|
138
|
+
super(refused);
|
|
139
|
+
this.refused = refused;
|
|
140
|
+
this.retryAfterMs = retryAfterMs;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const errName = (err: unknown): string => {
|
|
145
|
+
try {
|
|
146
|
+
return err instanceof Error ? err.name : typeof err;
|
|
147
|
+
} catch {
|
|
148
|
+
return 'unknown';
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
/** The stored rule text as a rule reference, or null for none or a value that is not one. */
|
|
153
|
+
export function ruleRefOf(text: string | null): RuleRef | null {
|
|
154
|
+
if (text === null) return null;
|
|
155
|
+
try {
|
|
156
|
+
return parseRuleRef(text);
|
|
157
|
+
} catch {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const NOT_FOUND = { ok: false, refused: 'not_found' } as const;
|
|
163
|
+
|
|
164
|
+
export class AppealService {
|
|
165
|
+
private readonly d: AppealServiceDeps;
|
|
166
|
+
|
|
167
|
+
constructor(deps: AppealServiceDeps) {
|
|
168
|
+
this.d = deps;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** Appeals are on in the profile in force AND the store can keep them. */
|
|
172
|
+
enabled(): boolean {
|
|
173
|
+
return this.d.settings().enabled && hasAppealMethods(this.d.store);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
private warn(err: unknown): void {
|
|
177
|
+
safeWarn(this.d.logger, 'chatwarden.appeal_failed', { error: errName(err) });
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
file(who: RawWho, input: { noticeId: string; statement: string }): AppealFileResult {
|
|
181
|
+
if (!this.enabled()) return { ok: false, refused: 'off' };
|
|
182
|
+
try {
|
|
183
|
+
return this.fileInner(who, input);
|
|
184
|
+
} catch (err) {
|
|
185
|
+
// A store failure reads as "no such notice": the player is told nothing about the kit's health, the operator gets the class.
|
|
186
|
+
this.warn(err);
|
|
187
|
+
return NOT_FOUND;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
private fileInner(who: RawWho, input: { noticeId: string; statement: string }): AppealFileResult {
|
|
192
|
+
if (typeof who !== 'object' || who === null || typeof input !== 'object' || input === null) return NOT_FOUND;
|
|
193
|
+
const noticeId: unknown = input.noticeId;
|
|
194
|
+
const subject = this.d.personOf(who);
|
|
195
|
+
if (subject === null || typeof noticeId !== 'string' || noticeId === '') return NOT_FOUND;
|
|
196
|
+
const notice = this.d.notices.ownRow(subject, noticeId);
|
|
197
|
+
if (notice === null) return NOT_FOUND;
|
|
198
|
+
const now = this.d.clock.now();
|
|
199
|
+
if (notice.groupId === null || !appliesInRecord(notice, now)) return { ok: false, refused: 'not_appealable' };
|
|
200
|
+
|
|
201
|
+
const statement = normalizeStatement(input.statement);
|
|
202
|
+
if (statement === '' || statementLength(statement) > APPEAL_STATEMENT_MAX) return { ok: false, refused: 'statement_invalid' };
|
|
203
|
+
|
|
204
|
+
const group = this.d.store.loadSanctionSubjectRow?.(notice.groupId) ?? null;
|
|
205
|
+
// The notice outlived its sanction rows (retention): there is nothing left to appeal.
|
|
206
|
+
if (group === null || group.revokedAt !== undefined) return { ok: false, refused: 'not_appealable' };
|
|
207
|
+
|
|
208
|
+
const person = this.d.subjects.canonical(subject);
|
|
209
|
+
const aliases = this.d.subjects.aliasesOf(person);
|
|
210
|
+
const cap = this.d.settings().perPlayerPerWeek;
|
|
211
|
+
const row: AppealRow = {
|
|
212
|
+
id: randomId(16),
|
|
213
|
+
subject: person,
|
|
214
|
+
groupId: notice.groupId,
|
|
215
|
+
noticeId: notice.id,
|
|
216
|
+
reportId: group.reportId ?? null,
|
|
217
|
+
rule: group.rule,
|
|
218
|
+
kind: group.kind,
|
|
219
|
+
statement,
|
|
220
|
+
status: 'open',
|
|
221
|
+
createdAt: now,
|
|
222
|
+
decidedAt: null,
|
|
223
|
+
decidedBy: null,
|
|
224
|
+
decisionReason: null,
|
|
225
|
+
replacementGroupId: null,
|
|
226
|
+
};
|
|
227
|
+
const since = now - WEEK_MS + 1; // a row exactly a week old has left the window
|
|
228
|
+
try {
|
|
229
|
+
this.d.store.transaction(() => {
|
|
230
|
+
// The unique group decides "already appealed" in the same statement that writes the row, so of two filings exactly one wins; the
|
|
231
|
+
// rate is then counted with the new row in it. Either refusal rolls the row back: a refusal writes nothing. The sanction is read
|
|
232
|
+
// again here: a revoke by another process may have committed since the read above, and its hook cannot have closed a row that
|
|
233
|
+
// did not exist yet.
|
|
234
|
+
const live = this.d.store.loadSanctionSubjectRow?.(row.groupId) ?? null;
|
|
235
|
+
if (live === null || live.revokedAt !== undefined) throw new Refuse('not_appealable');
|
|
236
|
+
if (this.d.store.insertAppeal?.(row) !== true) throw new Refuse('already_appealed');
|
|
237
|
+
const count = this.d.store.countAppealsBy?.(aliases, since) ?? { count: 0, oldestAt: null };
|
|
238
|
+
if (count.count > cap) throw new Refuse('rate', Math.max(1, (count.oldestAt ?? now) + WEEK_MS - now));
|
|
239
|
+
});
|
|
240
|
+
} catch (err) {
|
|
241
|
+
if (err instanceof Refuse) {
|
|
242
|
+
if (err.refused === 'rate') return { ok: false, refused: 'rate', retryAfterMs: err.retryAfterMs ?? 1 };
|
|
243
|
+
return { ok: false, refused: err.refused };
|
|
244
|
+
}
|
|
245
|
+
throw err;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
try {
|
|
249
|
+
this.d.emit({ type: 'appeal.created', appealId: row.id, createdAt: row.createdAt, target: person, kind: row.kind, rule: ruleRefOf(row.rule) });
|
|
250
|
+
} catch (err) {
|
|
251
|
+
safeWarn(this.d.logger, 'chatwarden.event_failed', { error: errName(err) });
|
|
252
|
+
}
|
|
253
|
+
return { ok: true, appeal: toPlayerAppeal(row) };
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Decide an open appeal, once. One store transaction: the sanction is revoked (reduce, revoke), the replacement written (reduce), the
|
|
258
|
+
* player's notices made, and the appeal moved from open only, so a second decision, or one made while another process decides, finds it
|
|
259
|
+
* decided and changes nothing. Checks, in order: a well-formed decision (`invalid`), the appeal (`not_found`, `already_decided`), the
|
|
260
|
+
* sanction still standing (`gone`, which also makes the appeal moot), independence (`same_decider`), and for a reduction that `to` is
|
|
261
|
+
* lighter (`invalid`). A STORE failure rejects and writes nothing. After the commit, each fenced: the player is told, the sanction index
|
|
262
|
+
* updated and `appeal.decided` emitted.
|
|
263
|
+
*/
|
|
264
|
+
async decide(input: AppealDecision): Promise<AppealDecideResult> {
|
|
265
|
+
if (!this.enabled()) return { ok: false, error: 'not_found' };
|
|
266
|
+
const d = checkDecision(input);
|
|
267
|
+
if (d === null) return INVALID;
|
|
268
|
+
try {
|
|
269
|
+
return this.decideChecked(d);
|
|
270
|
+
} catch (err) {
|
|
271
|
+
this.warn(err);
|
|
272
|
+
throw err;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
private decideChecked(d: CheckedDecision): AppealDecideResult {
|
|
277
|
+
const { store, subjects, clock, notices } = this.d;
|
|
278
|
+
const now = clock.now();
|
|
279
|
+
const appeal = store.loadAppeal?.(d.appealId) ?? null;
|
|
280
|
+
if (appeal === null) return { ok: false, error: 'not_found' };
|
|
281
|
+
// A moot appeal means its sanction was revoked first: that is `gone`. Any other closed appeal was decided.
|
|
282
|
+
if (appeal.status === 'moot') return { ok: false, error: 'gone' };
|
|
283
|
+
if (appeal.status !== 'open') return { ok: false, error: 'already_decided' };
|
|
284
|
+
const group = store.loadSanctionSubjectRow?.(appeal.groupId) ?? null;
|
|
285
|
+
// The sanction is gone (retention) or was revoked by a path that did not make the appeal moot: nothing is left to rule on.
|
|
286
|
+
if (group === null || group.revokedAt !== undefined) return this.mootGone(appeal, d.actor, now);
|
|
287
|
+
if (!this.d.settings().allowSelfReview && !group.automated && group.actor === d.actor) return { ok: false, error: 'same_decider' };
|
|
288
|
+
const plan = d.outcome === 'reduce' ? reductionOf(group, d.to) : null;
|
|
289
|
+
if (d.outcome === 'reduce' && plan === null) return INVALID;
|
|
290
|
+
|
|
291
|
+
const person = subjects.canonical(appeal.subject);
|
|
292
|
+
const clear = this.d.clearStatements();
|
|
293
|
+
const pending = !this.d.index.isEnabled();
|
|
294
|
+
let written: ReturnType<typeof writeSanction> | null = null;
|
|
295
|
+
try {
|
|
296
|
+
store.transaction(() => {
|
|
297
|
+
if (d.outcome !== 'uphold') {
|
|
298
|
+
// Straight to the store, not `revokeSanction`: that would make this very appeal moot before it is decided.
|
|
299
|
+
if (store.revokeSanctionGroup(appeal.groupId, d.actor, now, d.reason) === 0) throw new Stop('gone');
|
|
300
|
+
notices.withdrawGroup(appeal.groupId);
|
|
301
|
+
}
|
|
302
|
+
if (plan !== null) {
|
|
303
|
+
written = writeSanction(
|
|
304
|
+
store,
|
|
305
|
+
subjects,
|
|
306
|
+
{
|
|
307
|
+
kind: plan.kind,
|
|
308
|
+
subject: person,
|
|
309
|
+
includeIp: false,
|
|
310
|
+
durationMs: plan.durationMs,
|
|
311
|
+
reason: d.reason,
|
|
312
|
+
actor: d.actor,
|
|
313
|
+
source: 'moderator',
|
|
314
|
+
automated: false,
|
|
315
|
+
rule: appeal.rule === null ? 'uncovered' : (ruleRefOf(appeal.rule) ?? 'uncovered'),
|
|
316
|
+
roomId: group.roomId,
|
|
317
|
+
startsAt: group.startsAt,
|
|
318
|
+
startsAtToken: APPEALS_START_TOKEN,
|
|
319
|
+
},
|
|
320
|
+
now,
|
|
321
|
+
pending,
|
|
322
|
+
);
|
|
323
|
+
notices.createForSanction(
|
|
324
|
+
{ groupId: written.groupId, refCode: written.refCode, kind: plan.kind, until: plan.kind === 'warning' ? null : written.endsAt, rule: ruleRefOf(appeal.rule), subject: person },
|
|
325
|
+
[],
|
|
326
|
+
{ notify: false },
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
notices.createMessage(person, OUTCOME_NOTICE[d.outcome], { rule: ruleRefOf(appeal.rule), refCode: group.refCode, notify: false });
|
|
330
|
+
const moved = store.decideAppeal?.(appeal.id, {
|
|
331
|
+
status: OUTCOME_STATUS[d.outcome],
|
|
332
|
+
at: now,
|
|
333
|
+
by: d.actor,
|
|
334
|
+
reason: d.reason,
|
|
335
|
+
replacementGroupId: written === null ? null : (written as ReturnType<typeof writeSanction>).groupId,
|
|
336
|
+
...(clear ? { clearStatement: true } : {}),
|
|
337
|
+
});
|
|
338
|
+
if (moved !== true) throw new Stop('already_decided');
|
|
339
|
+
if (d.outcome !== 'uphold' && appeal.reportId !== null) {
|
|
340
|
+
try {
|
|
341
|
+
this.d.onGranted?.(appeal, d.outcome);
|
|
342
|
+
} catch (err) {
|
|
343
|
+
this.warn(err);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
} catch (err) {
|
|
348
|
+
if (err instanceof Stop) {
|
|
349
|
+
if (err.why !== 'gone') return { ok: false, error: 'already_decided' };
|
|
350
|
+
// The revoke found nothing to revoke. When another process decided this appeal first (and so revoked or replaced the group), this
|
|
351
|
+
// call lost the race and the answer is `already_decided`; only an appeal still open has really lost its sanction.
|
|
352
|
+
const now_ = store.loadAppeal?.(appeal.id) ?? null;
|
|
353
|
+
if (now_ !== null && now_.status !== 'open') return { ok: false, error: now_.status === 'moot' ? 'gone' : 'already_decided' };
|
|
354
|
+
return this.mootGone(appeal, d.actor, now);
|
|
355
|
+
}
|
|
356
|
+
throw err;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// Committed. Each of these is fenced: none can fail a decision that is already made.
|
|
360
|
+
const fenced = (what: () => void): void => {
|
|
361
|
+
try {
|
|
362
|
+
what();
|
|
363
|
+
} catch (err) {
|
|
364
|
+
safeWarn(this.d.logger, 'chatwarden.event_failed', { error: errName(err) });
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
if (d.outcome !== 'uphold') fenced(() => this.d.index.remove(appeal.groupId));
|
|
368
|
+
const made = written as ReturnType<typeof writeSanction> | null;
|
|
369
|
+
if (made !== null) fenced(() => this.d.index.add(made.rows, now));
|
|
370
|
+
fenced(() => notices.announce(person));
|
|
371
|
+
fenced(() => this.d.emit({ type: 'appeal.decided', appealId: appeal.id, at: now, target: person, outcome: d.outcome, rule: ruleRefOf(appeal.rule) }));
|
|
372
|
+
return { ok: true, status: OUTCOME_STATUS[d.outcome], ...(made === null ? {} : { replacementGroupId: made.groupId }) };
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/** The sanction is gone: close the appeal as moot (committed, unlike a refusal) and say so. Nothing is announced or marked. */
|
|
376
|
+
private mootGone(appeal: AppealRow, by: string, now: number): AppealDecideResult {
|
|
377
|
+
this.d.store.transaction(() => this.d.store.closeAppealsForGroup?.(appeal.groupId, by, now, this.d.clearStatements()));
|
|
378
|
+
return { ok: false, error: 'gone' };
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// --- staff reads ----------------------------------------------------------------------------------------------------------
|
|
382
|
+
|
|
383
|
+
/** Whether `statement` trips the term filter now. A matcher that throws reads as not flagged (logged by class), like the chat path. */
|
|
384
|
+
private flagged(statement: string | null): boolean {
|
|
385
|
+
if (statement === null || this.d.matcher === undefined) return false;
|
|
386
|
+
try {
|
|
387
|
+
return this.d.matcher.match(statement) !== null;
|
|
388
|
+
} catch (err) {
|
|
389
|
+
this.warn(err);
|
|
390
|
+
return false;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
private summaryOf(r: AppealRow): AppealSummary {
|
|
395
|
+
const g = this.d.store.loadSanctionSubjectRow?.(r.groupId) ?? null;
|
|
396
|
+
return {
|
|
397
|
+
id: r.id,
|
|
398
|
+
createdAt: r.createdAt,
|
|
399
|
+
status: r.status,
|
|
400
|
+
person: this.d.subjects.canonical(r.subject),
|
|
401
|
+
// The sanction rows can be gone (retention): the appeal still lists, from its own row.
|
|
402
|
+
sanction:
|
|
403
|
+
g === null
|
|
404
|
+
? { groupId: r.groupId, refCode: '', kind: r.kind, rule: ruleRefOf(r.rule), startsAt: r.createdAt, endsAt: null, decidedBy: '', automated: false }
|
|
405
|
+
: { groupId: g.groupId, refCode: g.refCode, kind: g.kind, rule: ruleRefOf(g.rule), startsAt: g.startsAt, endsAt: g.endsAt, decidedBy: g.actor, automated: g.automated },
|
|
406
|
+
statementFlagged: this.flagged(r.statement),
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* The inbox, oldest first: `open` (default), `decided` or `all`; `limit` 1 to 200 (default 50); `cursor` the `next` of the previous page.
|
|
412
|
+
* A summary never carries the statement. A moot appeal is not listed. `RangeError` for a bad status, limit or cursor. Empty with appeals off.
|
|
413
|
+
*/
|
|
414
|
+
list(q: { status?: 'open' | 'decided' | 'all'; limit?: number; cursor?: string | null }): AppealPage {
|
|
415
|
+
if (!this.enabled()) return { items: [], next: null };
|
|
416
|
+
const query: { status?: unknown; limit?: unknown; cursor?: unknown } = typeof q === 'object' && q !== null ? q : {};
|
|
417
|
+
const status = query.status === undefined ? 'open' : query.status;
|
|
418
|
+
if (status !== 'open' && status !== 'decided' && status !== 'all') throw new RangeError('appeals.list: status must be open, decided or all');
|
|
419
|
+
const limit = query.limit === undefined ? 50 : query.limit;
|
|
420
|
+
if (typeof limit !== 'number' || !Number.isInteger(limit) || limit < 1 || limit > 200) throw new RangeError('appeals.list: limit must be an integer from 1 to 200');
|
|
421
|
+
const after = query.cursor === undefined || query.cursor === null ? undefined : decodeCursor(query.cursor);
|
|
422
|
+
try {
|
|
423
|
+
const rows = this.d.store.listAppeals?.({ status, limit, ...(after === undefined ? {} : { after }) }) ?? [];
|
|
424
|
+
const last = rows[rows.length - 1];
|
|
425
|
+
return { items: rows.map((r) => this.summaryOf(r)), next: rows.length === limit && last !== undefined ? b64urlEncode(`${last.createdAt}:${last.id}`) : null };
|
|
426
|
+
} catch (err) {
|
|
427
|
+
this.warn(err);
|
|
428
|
+
return { items: [], next: null };
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* One person's appeals as summaries, newest first, at most 50, a moot one left out. Listed while appeals are off too (what was filed stays
|
|
434
|
+
* visible on the person's page until retention removes it, as with `renamesOf`); empty for a store that cannot keep appeals, an unknown
|
|
435
|
+
* person and on a store failure. Staff only.
|
|
436
|
+
*/
|
|
437
|
+
forPerson(subject: SubjectId): AppealSummary[] {
|
|
438
|
+
if (!hasAppealMethods(this.d.store) || typeof subject !== 'string' || subject === '') return [];
|
|
439
|
+
try {
|
|
440
|
+
const person = this.d.subjects.canonical(subject);
|
|
441
|
+
return (this.d.store.listAppealsBy?.(this.d.subjects.aliasesOf(person), MINE_MAX) ?? []).filter((r) => r.status !== 'moot').map((r) => this.summaryOf(r));
|
|
442
|
+
} catch (err) {
|
|
443
|
+
this.warn(err);
|
|
444
|
+
return [];
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/** One appeal in full (the statement included), or null for an unknown id, a store failure, or with appeals off. */
|
|
449
|
+
get(id: string): AppealDetail | null {
|
|
450
|
+
if (!this.enabled() || typeof id !== 'string' || id === '') return null;
|
|
451
|
+
try {
|
|
452
|
+
const r = this.d.store.loadAppeal?.(id) ?? null;
|
|
453
|
+
if (r === null) return null;
|
|
454
|
+
const aliases = this.d.subjects.aliasesOf(this.d.subjects.canonical(r.subject));
|
|
455
|
+
const notice = this.d.store.loadNotices(aliases).find((n) => n.id === r.noticeId);
|
|
456
|
+
return {
|
|
457
|
+
...this.summaryOf(r),
|
|
458
|
+
statement: r.statement,
|
|
459
|
+
decided: r.decidedAt === null || r.decidedBy === null ? null : { by: r.decidedBy, at: r.decidedAt, reason: r.decisionReason ?? '', replacementGroupId: r.replacementGroupId },
|
|
460
|
+
reportId: r.reportId,
|
|
461
|
+
shown: notice === undefined ? [] : notice.excerpt.map((l) => ({ text: l.text, day: l.day })),
|
|
462
|
+
};
|
|
463
|
+
} catch (err) {
|
|
464
|
+
this.warn(err);
|
|
465
|
+
return null;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
/** How many appeals are waiting. 0 with appeals off or on a store failure. */
|
|
470
|
+
openCount(): number {
|
|
471
|
+
if (!this.enabled()) return 0;
|
|
472
|
+
try {
|
|
473
|
+
return this.d.store.countOpenAppeals?.() ?? 0;
|
|
474
|
+
} catch (err) {
|
|
475
|
+
this.warn(err);
|
|
476
|
+
return 0;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Per rule over the last 30, 90 (default) or 365 days: the sanctions given, the appeals filed, how many were revoked (`granted`, the
|
|
482
|
+
* only ones that count as wrong) and how many reduced (`lightened`, shown beside the rate, never in it). The rate is granted over
|
|
483
|
+
* sanctions, null below ten sanctions; `high` from 0.30, `elevated` from 0.15. `RangeError` for any other window.
|
|
484
|
+
*/
|
|
485
|
+
stats(q?: { days?: 30 | 90 | 365 }): AppealStats {
|
|
486
|
+
const days: unknown = q === undefined || q === null || q.days === undefined ? 90 : q.days;
|
|
487
|
+
if (days !== 30 && days !== 90 && days !== 365) throw new RangeError('appeals.stats: days must be 30, 90 or 365');
|
|
488
|
+
const empty: AppealStats = { windowDays: days, perRule: [], overall: { sanctions: 0, appealed: 0, granted: 0, lightened: 0, rate: null } };
|
|
489
|
+
if (!this.enabled()) return empty;
|
|
490
|
+
try {
|
|
491
|
+
const since = this.d.clock.now() - days * 86_400_000;
|
|
492
|
+
const byRule = new Map<number | 'uncovered', { sanctions: number; appealed: number; granted: number; lightened: number }>();
|
|
493
|
+
const slot = (rule: string | null) => {
|
|
494
|
+
const key: number | 'uncovered' = rule === null || rule === 'uncovered' ? 'uncovered' : (ruleRefOf(rule) as number | 'uncovered' | null) ?? 'uncovered';
|
|
495
|
+
let c = byRule.get(key);
|
|
496
|
+
if (c === undefined) byRule.set(key, (c = { sanctions: 0, appealed: 0, granted: 0, lightened: 0 }));
|
|
497
|
+
return c;
|
|
498
|
+
};
|
|
499
|
+
for (const r of this.d.store.countSanctionsByRule?.(since) ?? []) slot(r.rule).sanctions += r.count;
|
|
500
|
+
for (const r of this.d.store.appealCountsByRule?.(since) ?? []) {
|
|
501
|
+
const c = slot(r.rule);
|
|
502
|
+
c.appealed += r.appealed;
|
|
503
|
+
c.granted += r.granted;
|
|
504
|
+
c.lightened += r.lightened;
|
|
505
|
+
}
|
|
506
|
+
const perRule: AppealRuleStats[] = [...byRule.entries()]
|
|
507
|
+
.sort(([a], [b]) => (a === 'uncovered' ? 1 : b === 'uncovered' ? -1 : a - b))
|
|
508
|
+
.map(([rule, c]) => ({ rule, ...c, ...rateOf(c.granted, c.sanctions) }));
|
|
509
|
+
const sum = perRule.reduce((t, r) => ({ sanctions: t.sanctions + r.sanctions, appealed: t.appealed + r.appealed, granted: t.granted + r.granted, lightened: t.lightened + r.lightened }), { sanctions: 0, appealed: 0, granted: 0, lightened: 0 });
|
|
510
|
+
return { windowDays: days, perRule, overall: { ...sum, rate: rateOf(sum.granted, sum.sanctions).rate } };
|
|
511
|
+
} catch (err) {
|
|
512
|
+
this.warn(err);
|
|
513
|
+
return empty;
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* The rules whose revoke-on-appeal rate over 90 days is `elevated` or `high`, as rule numbers and bands only, for the AI read. A reduction is
|
|
519
|
+
* not a revoke, so a rule with many reduces and no revokes is never listed. Empty with appeals off.
|
|
520
|
+
*/
|
|
521
|
+
cautions(): Array<{ rule: number; band: 'elevated' | 'high' }> {
|
|
522
|
+
if (!this.enabled()) return [];
|
|
523
|
+
return this.stats({ days: 90 }).perRule.flatMap((r) => (typeof r.rule === 'number' && (r.band === 'elevated' || r.band === 'high') ? [{ rule: r.rule, band: r.band }] : []));
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
mine(who: RawWho): PlayerAppeal[] {
|
|
527
|
+
if (!this.enabled()) return [];
|
|
528
|
+
try {
|
|
529
|
+
if (typeof who !== 'object' || who === null) return [];
|
|
530
|
+
const subject = this.d.personOf(who);
|
|
531
|
+
if (subject === null) return [];
|
|
532
|
+
const person = this.d.subjects.canonical(subject);
|
|
533
|
+
return (this.d.store.listAppealsBy?.(this.d.subjects.aliasesOf(person), MINE_MAX) ?? []).filter((r) => r.status !== 'moot').map(toPlayerAppeal);
|
|
534
|
+
} catch (err) {
|
|
535
|
+
this.warn(err);
|
|
536
|
+
return [];
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* What a reduction becomes: the kind and length of the replacement, or null when `to` is not lighter than the sanction (a lower kind, or the
|
|
543
|
+
* same kind and shorter, permanent being the longest; a warning cannot be reduced). The replacement keeps the original start and ends at
|
|
544
|
+
* the earlier of the original end and `start + to.durationMs`, so it is never later than the original.
|
|
545
|
+
*/
|
|
546
|
+
function reductionOf(group: SanctionRow, to: CheckedDecision['to']): { kind: 'warning' | 'chat' | 'area' | 'ban'; durationMs: number | null } | null {
|
|
547
|
+
if (to === null) return null;
|
|
548
|
+
const from = (SANCTION_KIND_ORDER as readonly string[]).indexOf(group.kind);
|
|
549
|
+
const target = (SANCTION_KIND_ORDER as readonly string[]).indexOf(to.kind);
|
|
550
|
+
if (from <= 0 || target < 0) return null; // not an appealable kind, or a warning (the lightest: nothing to reduce to)
|
|
551
|
+
const origLength = group.endsAt === null ? Infinity : group.endsAt - group.startsAt;
|
|
552
|
+
const newLength = to.durationMs === null ? Infinity : to.durationMs;
|
|
553
|
+
if (!(target < from || (target === from && newLength < origLength))) return null;
|
|
554
|
+
if (to.kind === 'warning') return { kind: 'warning', durationMs: null };
|
|
555
|
+
const end = to.durationMs === null ? group.endsAt : group.endsAt === null ? group.startsAt + to.durationMs : Math.min(group.endsAt, group.startsAt + to.durationMs);
|
|
556
|
+
if (end !== null && end <= group.startsAt) return null;
|
|
557
|
+
return { kind: to.kind, durationMs: end === null ? null : end - group.startsAt };
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/** The rate and its band: null below the minimum number of sanctions; `high` from 0.30, `elevated` from 0.15. */
|
|
561
|
+
function rateOf(granted: number, sanctions: number): { rate: number | null; band: 'normal' | 'elevated' | 'high' | null } {
|
|
562
|
+
if (sanctions < APPEAL_STATS_MIN_SANCTIONS) return { rate: null, band: null };
|
|
563
|
+
const rate = granted / sanctions;
|
|
564
|
+
return { rate, band: rate >= APPEAL_RATE_HIGH ? 'high' : rate >= APPEAL_RATE_ELEVATED ? 'elevated' : 'normal' };
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
/** The cursor of a page: base64url of `createdAt:id`. A value that is not one we issued is a `RangeError`. */
|
|
568
|
+
function decodeCursor(cursor: unknown): { createdAt: number; id: string } {
|
|
569
|
+
const text = typeof cursor === 'string' ? b64urlDecode(cursor) : null;
|
|
570
|
+
const sep = text === null ? -1 : text.indexOf(':');
|
|
571
|
+
if (text === null || sep < 1 || sep === text.length - 1 || !/^\d{1,16}$/.test(text.slice(0, sep))) throw new RangeError('appeals.list: invalid cursor');
|
|
572
|
+
return { createdAt: Number(text.slice(0, sep)), id: text.slice(sep + 1) };
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/** What a player may see of an appeal row: no staff ref, reason, sanction or person id. A moot appeal is never shown to a player. */
|
|
576
|
+
export function toPlayerAppeal(r: AppealRow): PlayerAppeal {
|
|
577
|
+
return {
|
|
578
|
+
id: r.id,
|
|
579
|
+
noticeId: r.noticeId,
|
|
580
|
+
status: r.status as PlayerAppeal['status'],
|
|
581
|
+
createdAt: r.createdAt,
|
|
582
|
+
decidedAt: r.decidedAt,
|
|
583
|
+
};
|
|
584
|
+
}
|