underscores for private vars are not proper

This commit is contained in:
jesopo 2022-03-28 09:27:22 +00:00
parent fbe90ff835
commit e34d542cb2

View File

@ -20,33 +20,33 @@ import { ReportManager } from './ReportManager';
class InvalidStateError extends Error {}
export class ReportPoll {
private _client: MatrixClient;
private _manager: ReportManager;
private _save: (a: number) => Promise<any>;
private _from = 0;
private client: MatrixClient;
private manager: ReportManager;
private save: (a: number) => Promise<any>;
private from = 0;
private _interval: ReturnType<typeof setInterval> | null = null;
private interval: ReturnType<typeof setInterval> | null = null;
constructor(
client: MatrixClient,
manager: ReportManager,
save: (a: number) => Promise<any>
) {
this._client = client;
this._manager = manager;
this._save = save;
this.client = client;
this.manager = manager;
this.save = save;
}
private async getAbuseReports(): Promise<any> {
const response = await this._client.doRequest(
const response = await this.client.doRequest(
"GET",
"/_synapse/admin/v1/event_reports",
{ from: this._from.toString() }
{ from: this.from.toString() }
);
for (let report of response.event_reports) {
const event = await this._client.getEvent(report.room_id, report.event_id);
await this._manager.handleServerAbuseReport({
const event = await this.client.getEvent(report.room_id, report.event_id);
await this.manager.handleServerAbuseReport({
roomId: report.room_id,
reporterId: report.sender,
event: event,
@ -55,16 +55,16 @@ export class ReportPoll {
}
if (response.next_token !== undefined) {
this._from = response.next_token;
await this._save(response.next_token);
this.from = response.next_token;
await this.save(response.next_token);
}
}
public start(startFrom: number) {
if (this._interval === null) {
this._from = startFrom;
if (this.interval === null) {
this.from = startFrom;
const self = this;
this._interval = setInterval(
this.interval = setInterval(
function() { self.getAbuseReports() },
60_000
);
@ -73,9 +73,9 @@ export class ReportPoll {
}
}
public stop() {
if (this._interval !== null) {
clearInterval(this._interval);
this._interval = null;
if (this.interval !== null) {
clearInterval(this.interval);
this.interval = null;
} else {
throw new InvalidStateError();
}