mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 21:15:32 +09:00
feat(admin): add warning given report outcome (#3500)
This commit is contained in:
1 parent
61a4e3895a
commit
9000a9f4c7
9 files changed
+34
-14
No files matched your search
@@ -33,6 +33,8 @@ interface ReporterNoticeResult {
|
||||
skipped: ReporterNoticeSkipReason | null;
|
||||
}
|
||||
|
||||
type ReporterToldOutcome = Exclude<ReportItemOutcome, 'warned'>;
|
||||
|
||||
function skippedNotice(reason: ReporterNoticeSkipReason): ReporterNoticeResult {
|
||||
return {dmSent: false, emailSent: false, dsaEmailSent: false, skipped: reason};
|
||||
}
|
||||
@@ -59,17 +61,18 @@ export class ReporterResolutionNotifier {
|
||||
outcome: ReportItemOutcome,
|
||||
): Promise<ReporterNoticeResult> {
|
||||
const comment = publicComment ?? '';
|
||||
const told = outcome === 'warned' ? 'action_taken' : outcome;
|
||||
if (report.reporterId) {
|
||||
return this.notifyAccountReporter(report, report.reporterId, comment, outcome);
|
||||
return this.notifyAccountReporter(report, report.reporterId, comment, told);
|
||||
}
|
||||
return this.notifyDsaReporter(report, comment, outcome);
|
||||
return this.notifyDsaReporter(report, comment, told);
|
||||
}
|
||||
|
||||
private async notifyAccountReporter(
|
||||
report: IARSubmission,
|
||||
reporterId: UserID,
|
||||
comment: string,
|
||||
outcome: ReportItemOutcome,
|
||||
outcome: ReporterToldOutcome,
|
||||
): Promise<ReporterNoticeResult> {
|
||||
const {users: userRepository, email: emailService} = this.deps.apiContext.services;
|
||||
const reportId = report.reportId.toString();
|
||||
@@ -115,7 +118,7 @@ export class ReporterResolutionNotifier {
|
||||
private async notifyDsaReporter(
|
||||
report: IARSubmission,
|
||||
comment: string,
|
||||
outcome: ReportItemOutcome,
|
||||
outcome: ReporterToldOutcome,
|
||||
): Promise<ReporterNoticeResult> {
|
||||
const email = report.reporterEmail;
|
||||
if (!email) {
|
||||
@@ -134,7 +137,7 @@ export class ReporterResolutionNotifier {
|
||||
reporter: User,
|
||||
reportId: string,
|
||||
comment: string,
|
||||
outcome: ReportItemOutcome,
|
||||
outcome: ReporterToldOutcome,
|
||||
): Promise<boolean> {
|
||||
const systemDm = this.deps.systemDm;
|
||||
if (!systemDm) {
|
||||
|
||||
@@ -333,7 +333,7 @@ describe('Admin staff notifications', () => {
|
||||
expect(dm?.content).toContain('We found that what you reported broke our rules, and we took action.');
|
||||
expect(dm?.content).not.toMatch(/warn|restricted|suspend/i);
|
||||
const metadata = await auditMetadata('resolve_report', reportId);
|
||||
expect(metadata?.get('outcome')).toBe('action_taken');
|
||||
expect(metadata?.get('outcome')).toBe('warned');
|
||||
expect(metadata?.get('reporter_dm_sent')).toBe('true');
|
||||
});
|
||||
|
||||
@@ -347,6 +347,18 @@ describe('Admin staff notifications', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
test('a DSA notice resolved with a warning emails other action taken', async () => {
|
||||
const {email, reportId} = await fileDsaGuildNotice();
|
||||
await clearTestEmails(harness);
|
||||
await resolve(reportId, {outcome: 'warned'});
|
||||
const sent = await listTestEmails(harness, {recipient: email});
|
||||
expect(sent.map((entry) => [entry.type, entry.metadata.outcome])).toEqual([
|
||||
['dsa_report_resolved', 'action_taken'],
|
||||
]);
|
||||
const metadata = await auditMetadata('resolve_report', reportId);
|
||||
expect(metadata?.get('outcome')).toBe('warned');
|
||||
});
|
||||
|
||||
test('a DSA notice resolved with notify_reporter false gets the decision email without the comment', async () => {
|
||||
const {email, reportId} = await fileDsaGuildNotice();
|
||||
await clearTestEmails(harness);
|
||||
|
||||
@@ -239,7 +239,7 @@ function reportOutcome(
|
||||
(removeEvidence && evidence.some((message) => message.message_id === messageId));
|
||||
if (removed) return 'removed';
|
||||
}
|
||||
if (kind === 'warning') return 'action_taken';
|
||||
if (kind === 'warning') return 'warned';
|
||||
return RESTRICTING_KINDS.has(kind) ? 'restricted' : null;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user