mirror of
https://github.com/matrix-org/mjolnir.git
synced 2024-10-01 01:36:06 -04:00
wrap whole of getAbuseReports
in a try/catch
This commit is contained in:
parent
69f991aa9d
commit
122789ea5b
@ -48,7 +48,7 @@ export class ReportPoller {
|
|||||||
* of requests when networking problems resolve
|
* of requests when networking problems resolve
|
||||||
*/
|
*/
|
||||||
this.timeout = setTimeout(
|
this.timeout = setTimeout(
|
||||||
this.getAbuseReports.bind(this),
|
this.tryGetAbuseReports.bind(this),
|
||||||
60_000 // a minute in milliseconds
|
60_000 // a minute in milliseconds
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -57,8 +57,6 @@ export class ReportPoller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async getAbuseReports() {
|
private async getAbuseReports() {
|
||||||
this.timeout = null;
|
|
||||||
|
|
||||||
let response_: {
|
let response_: {
|
||||||
event_reports: { room_id: string, event_id: string, sender: string, reason: string }[],
|
event_reports: { room_id: string, event_id: string, sender: string, reason: string }[],
|
||||||
next_token: number | undefined
|
next_token: number | undefined
|
||||||
@ -108,10 +106,19 @@ export class ReportPoller {
|
|||||||
await this.mjolnir.logMessage(LogLevel.ERROR, "getAbuseReports", `failed to update progress: ${ex}`);
|
await this.mjolnir.logMessage(LogLevel.ERROR, "getAbuseReports", `failed to update progress: ${ex}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async tryGetAbuseReports() {
|
||||||
|
this.timeout = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await this.getAbuseReports()
|
||||||
|
} catch (ex) {
|
||||||
|
await this.mjolnir.logMessage(LogLevel.ERROR, "tryGetAbuseReports", `failed to get abuse reports: ${ex}`);
|
||||||
|
}
|
||||||
|
|
||||||
this.schedulePoll();
|
this.schedulePoll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public start(startFrom: number) {
|
public start(startFrom: number) {
|
||||||
if (this.timeout === null) {
|
if (this.timeout === null) {
|
||||||
this.from = startFrom;
|
this.from = startFrom;
|
||||||
|
Loading…
Reference in New Issue
Block a user