From ce78c5e6cac0c0891b296d19785b3e890311547b Mon Sep 17 00:00:00 2001 From: jesopo Date: Fri, 1 Jul 2022 13:29:21 +0000 Subject: [PATCH] documentation --- src/Mjolnir.ts | 4 ++++ src/report/ReportPoller.ts | 17 ++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Mjolnir.ts b/src/Mjolnir.ts index 8766cbc..fc32165 100644 --- a/src/Mjolnir.ts +++ b/src/Mjolnir.ts @@ -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 WARN_UNPROTECTED_ROOM_EVENT_PREFIX = "org.matrix.mjolnir.unprotected_room_warning.for."; 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 class Mjolnir { diff --git a/src/report/ReportPoller.ts b/src/report/ReportPoller.ts index 23bc296..a0dbebf 100644 --- a/src/report/ReportPoller.ts +++ b/src/report/ReportPoller.ts @@ -20,20 +20,23 @@ import { LogLevel } from "matrix-bot-sdk"; 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 { - /* + /** * 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 */ private from = 0; + /** + * The currently-pending report poll + */ private timeout: ReturnType | 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( private mjolnir: Mjolnir, private manager: ReportManager,