documentation

This commit is contained in:
jesopo 2022-07-01 13:29:21 +00:00
parent 6e7546e649
commit ce78c5e6ca
2 changed files with 14 additions and 7 deletions

View File

@ -68,6 +68,10 @@ const ENABLED_PROTECTIONS_EVENT_TYPE = "org.matrix.mjolnir.enabled_protections";
const PROTECTED_ROOMS_EVENT_TYPE = "org.matrix.mjolnir.protected_rooms"; const PROTECTED_ROOMS_EVENT_TYPE = "org.matrix.mjolnir.protected_rooms";
const WARN_UNPROTECTED_ROOM_EVENT_PREFIX = "org.matrix.mjolnir.unprotected_room_warning.for."; const WARN_UNPROTECTED_ROOM_EVENT_PREFIX = "org.matrix.mjolnir.unprotected_room_warning.for.";
const CONSEQUENCE_EVENT_DATA = "org.matrix.mjolnir.consequence"; const CONSEQUENCE_EVENT_DATA = "org.matrix.mjolnir.consequence";
/**
* Synapse will tell us where we last got to on polling reports, so we need
* to store that for pagination on further polls
*/
export const REPORT_POLL_EVENT_TYPE = "org.matrix.mjolnir.report_poll"; export const REPORT_POLL_EVENT_TYPE = "org.matrix.mjolnir.report_poll";
export class Mjolnir { export class Mjolnir {

View File

@ -20,20 +20,23 @@ import { LogLevel } from "matrix-bot-sdk";
class InvalidStateError extends Error {} class InvalidStateError extends Error {}
/**
* A class to poll synapse's report endpoint, so we can act on new reports
*
* @param mjolnir The running Mjolnir instance
* @param manager The report manager in to which we feed new reports
*/
export class ReportPoller { export class ReportPoller {
/* /**
* https://matrix-org.github.io/synapse/latest/admin_api/event_reports.html * https://matrix-org.github.io/synapse/latest/admin_api/event_reports.html
* "from" is an opaque token that is returned from the API to paginate reports * "from" is an opaque token that is returned from the API to paginate reports
*/ */
private from = 0; private from = 0;
/**
* The currently-pending report poll
*/
private timeout: ReturnType<typeof setTimeout> | null = null; private timeout: ReturnType<typeof setTimeout> | null = null;
/**
* A class to poll synapse's report endpoint, so we can act on new reports
*
* @param mjolnir The running Mjolnir instance
* @param manager The report manager in to which we feed new reports
*/
constructor( constructor(
private mjolnir: Mjolnir, private mjolnir: Mjolnir,
private manager: ReportManager, private manager: ReportManager,