mirror of
https://github.com/matrix-org/mjolnir.git
synced 2024-10-01 05:36:06 +00:00
the less far event
propagates, the better
This commit is contained in:
parent
a6d444d837
commit
2b60f6addd
@ -838,19 +838,19 @@ export class Mjolnir {
|
|||||||
await this.printBanlistChanges(changes, banList, true);
|
await this.printBanlistChanges(changes, banList, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async handleConsequence(protection: Protection, roomId: string, event: any, consequence: Consequence) {
|
private async handleConsequence(protection: Protection, roomId: string, eventId: string, sender: string, consequence: Consequence) {
|
||||||
switch (consequence.type) {
|
switch (consequence.type) {
|
||||||
case ConsequenceType.alert:
|
case ConsequenceType.alert:
|
||||||
break;
|
break;
|
||||||
case ConsequenceType.redact:
|
case ConsequenceType.redact:
|
||||||
await this.client.redactEvent(roomId, event["event_id"], "abuse detected");
|
await this.client.redactEvent(roomId, eventId, "abuse detected");
|
||||||
break;
|
break;
|
||||||
case ConsequenceType.ban:
|
case ConsequenceType.ban:
|
||||||
await this.client.banUser(event["sender"], roomId, "abuse detected");
|
await this.client.banUser(sender, roomId, "abuse detected");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
let message = `protection ${protection.name} enacting ${ConsequenceType[consequence.type]} against ${htmlEscape(event["sender"])}`;
|
let message = `protection ${protection.name} enacting ${ConsequenceType[consequence.type]} against ${htmlEscape(sender)}`;
|
||||||
if (consequence.reason !== undefined) {
|
if (consequence.reason !== undefined) {
|
||||||
// even though internally-sourced, there's no promise that `consequence.reason`
|
// even though internally-sourced, there's no promise that `consequence.reason`
|
||||||
// will never have user-supplied information, so escape it
|
// will never have user-supplied information, so escape it
|
||||||
@ -861,7 +861,7 @@ export class Mjolnir {
|
|||||||
msgtype: "m.notice",
|
msgtype: "m.notice",
|
||||||
body: message,
|
body: message,
|
||||||
[CONSEQUENCE_EVENT_DATA]: {
|
[CONSEQUENCE_EVENT_DATA]: {
|
||||||
who: event["sender"],
|
who: sender,
|
||||||
room: roomId,
|
room: roomId,
|
||||||
type: ConsequenceType[consequence.type]
|
type: ConsequenceType[consequence.type]
|
||||||
}
|
}
|
||||||
@ -908,7 +908,7 @@ export class Mjolnir {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (consequence !== undefined) {
|
if (consequence !== undefined) {
|
||||||
await this.handleConsequence(protection, roomId, event, consequence);
|
await this.handleConsequence(protection, roomId, event["event_id"], event["sender"], consequence);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user