ability to disable displaying new reports in moderation room (#320)

This commit is contained in:
Jess Porter 2022-07-07 12:55:03 +01:00 committed by GitHub
parent 84ffb36494
commit b03d81dcc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 1 deletions

View File

@ -240,3 +240,7 @@ web:
# instead of intercepting client calls to synapse's abuse endpoint, when that # instead of intercepting client calls to synapse's abuse endpoint, when that
# isn't possible/practical. # isn't possible/practical.
pollReports: false pollReports: false
# Whether or not new reports, received either by webapi or polling,
# should be printed to our managementRoom.
displayReports: true

View File

@ -54,6 +54,11 @@ interface IConfig {
*/ */
backgroundDelayMS: number; backgroundDelayMS: number;
pollReports: boolean; pollReports: boolean;
/**
* Whether or not new reports, received either by webapi or polling,
* should be printed to our managementRoom.
*/
displayReports: boolean;
admin?: { admin?: {
enableMakeRoomAdminCommand?: boolean; enableMakeRoomAdminCommand?: boolean;
} }
@ -124,6 +129,7 @@ const defaultConfig: IConfig = {
protectAllJoinedRooms: false, protectAllJoinedRooms: false,
backgroundDelayMS: 500, backgroundDelayMS: 500,
pollReports: false, pollReports: false,
displayReports: true,
commands: { commands: {
allowNoPrefix: false, allowNoPrefix: false,
additionalPrefixes: [], additionalPrefixes: [],

View File

@ -21,6 +21,7 @@ import { htmlEscape } from "../utils";
import { JSDOM } from 'jsdom'; import { JSDOM } from 'jsdom';
import { EventEmitter } from 'events'; import { EventEmitter } from 'events';
import config from "../config";
import { Mjolnir } from "../Mjolnir"; import { Mjolnir } from "../Mjolnir";
/// Regexp, used to extract the action label from an action reaction /// Regexp, used to extract the action label from an action reaction
@ -114,7 +115,9 @@ export class ReportManager extends EventEmitter {
*/ */
public async handleServerAbuseReport({ roomId, reporterId, event, reason }: { roomId: string, reporterId: string, event: any, reason?: string }) { public async handleServerAbuseReport({ roomId, reporterId, event, reason }: { roomId: string, reporterId: string, event: any, reason?: string }) {
this.emit("report.new", { roomId: roomId, reporterId: reporterId, event: event, reason: reason }); this.emit("report.new", { roomId: roomId, reporterId: reporterId, event: event, reason: reason });
return this.displayManager.displayReportAndUI({ kind: Kind.SERVER_ABUSE_REPORT, event, reporterId, reason, moderationRoomId: this.mjolnir.managementRoomId }); if (config.displayReports) {
return this.displayManager.displayReportAndUI({ kind: Kind.SERVER_ABUSE_REPORT, event, reporterId, reason, moderationRoomId: this.mjolnir.managementRoomId });
}
} }
/** /**