Apply prettier formatting

This commit is contained in:
Michael Weimann 2022-12-12 12:24:14 +01:00
parent 1cac306093
commit 526645c791
No known key found for this signature in database
GPG key ID: 53F535A266BB9584
1576 changed files with 65385 additions and 62478 deletions

View file

@ -56,30 +56,35 @@ export class BanList {
}
get serverRules(): ListRule[] {
return this._rules.filter(r => r.kind === RULE_SERVER);
return this._rules.filter((r) => r.kind === RULE_SERVER);
}
get userRules(): ListRule[] {
return this._rules.filter(r => r.kind === RULE_USER);
return this._rules.filter((r) => r.kind === RULE_USER);
}
get roomRules(): ListRule[] {
return this._rules.filter(r => r.kind === RULE_ROOM);
return this._rules.filter((r) => r.kind === RULE_ROOM);
}
async banEntity(kind: string, entity: string, reason: string): Promise<any> {
await MatrixClientPeg.get().sendStateEvent(this._roomId, ruleTypeToStable(kind), {
entity: entity,
reason: reason,
recommendation: recommendationToStable(RECOMMENDATION_BAN, true),
}, "rule:" + entity);
await MatrixClientPeg.get().sendStateEvent(
this._roomId,
ruleTypeToStable(kind),
{
entity: entity,
reason: reason,
recommendation: recommendationToStable(RECOMMENDATION_BAN, true),
},
"rule:" + entity,
);
this._rules.push(new ListRule(entity, RECOMMENDATION_BAN, reason, ruleTypeToStable(kind)));
}
async unbanEntity(kind: string, entity: string): Promise<any> {
// Empty state event is effectively deleting it.
await MatrixClientPeg.get().sendStateEvent(this._roomId, ruleTypeToStable(kind), {}, "rule:" + entity);
this._rules = this._rules.filter(r => {
this._rules = this._rules.filter((r) => {
if (r.kind !== ruleTypeToStable(kind)) return true;
if (r.entity !== entity) return true;
return false; // we just deleted this rule
@ -99,9 +104,9 @@ export class BanList {
const kind = ruleTypeToStable(eventType);
const entity = ev.getContent()['entity'];
const recommendation = ev.getContent()['recommendation'];
const reason = ev.getContent()['reason'];
const entity = ev.getContent()["entity"];
const recommendation = ev.getContent()["recommendation"];
const reason = ev.getContent()["reason"];
if (!entity || !recommendation || !reason) continue;
this._rules.push(new ListRule(entity, recommendation, reason, kind));

View file

@ -53,12 +53,12 @@ export class Mjolnir {
this.dispatcherRef = dis.register(this.onAction);
dis.dispatch<DoAfterSyncPreparedPayload<ActionPayload>>({
action: Action.DoAfterSyncPrepared,
deferred_action: { action: 'setup_mjolnir' },
deferred_action: { action: "setup_mjolnir" },
});
}
private onAction = (payload: ActionPayload) => {
if (payload['action'] === 'setup_mjolnir') {
if (payload["action"] === "setup_mjolnir") {
logger.log("Setting up Mjolnir: after sync");
this.setup();
}
@ -93,17 +93,18 @@ export class Mjolnir {
topic: _t("This is your list of users/servers you have blocked - don't leave the room!"),
preset: Preset.PrivateChat,
});
personalRoomId = resp['room_id'];
await SettingsStore.setValue(
"mjolnirPersonalRoom", null, SettingLevel.ACCOUNT, personalRoomId);
await SettingsStore.setValue(
"mjolnirRooms", null, SettingLevel.ACCOUNT, [personalRoomId, ...this._roomIds]);
personalRoomId = resp["room_id"];
await SettingsStore.setValue("mjolnirPersonalRoom", null, SettingLevel.ACCOUNT, personalRoomId);
await SettingsStore.setValue("mjolnirRooms", null, SettingLevel.ACCOUNT, [
personalRoomId,
...this._roomIds,
]);
}
if (!personalRoomId) {
throw new Error("Error finding a room ID to use");
}
let list = this._lists.find(b => b.roomId === personalRoomId);
let list = this._lists.find((b) => b.roomId === personalRoomId);
if (!list) list = new BanList(personalRoomId);
// we don't append the list to the tracked rooms because it should already be there.
// we're just trying to get the caller some utility access to the list
@ -116,7 +117,7 @@ export class Mjolnir {
const personalRoomId = SettingsStore.getValue("mjolnirPersonalRoom");
if (!personalRoomId) return null;
let list = this._lists.find(b => b.roomId === personalRoomId);
let list = this._lists.find((b) => b.roomId === personalRoomId);
if (!list) list = new BanList(personalRoomId);
// we don't append the list to the tracked rooms because it should already be there.
// we're just trying to get the caller some utility access to the list
@ -131,9 +132,9 @@ export class Mjolnir {
}
async unsubscribeFromList(roomId: string) {
const roomIds = this._roomIds.filter(r => r !== roomId);
const roomIds = this._roomIds.filter((r) => r !== roomId);
await SettingsStore.setValue("mjolnirRooms", null, SettingLevel.ACCOUNT, roomIds);
this._lists = this._lists.filter(b => b.roomId !== roomId);
this._lists = this._lists.filter((b) => b.roomId !== roomId);
}
private onEvent = (event: MatrixEvent) => {
@ -192,4 +193,3 @@ export class Mjolnir {
return Mjolnir.instance;
}
}