mirror of
https://github.com/matrix-org/mjolnir.git
synced 2024-07-01 00:51:36 +00:00
Rename AutomaticRedactionQueue to UnlistedUserRedactionQueue.
This seems to be a more descriptive name and it also doesn't clash with the new redaction queue.
This commit is contained in:
parent
c949d26582
commit
2889599eb2
|
@ -34,7 +34,7 @@ import { logMessage } from "./LogProxy";
|
|||
import ErrorCache, { ERROR_KIND_FATAL, ERROR_KIND_PERMISSION } from "./ErrorCache";
|
||||
import { IProtection } from "./protections/IProtection";
|
||||
import { PROTECTIONS } from "./protections/protections";
|
||||
import { AutomaticRedactionQueue } from "./queues/AutomaticRedactionQueue";
|
||||
import { UnlistedUserRedactionQueue } from "./queues/UnlistedUserRedactionQueue";
|
||||
import { Healthz } from "./health/healthz";
|
||||
import { EventRedactionQueue, RedactUserInRoom } from "./queues/EventRedactionQueue";
|
||||
|
||||
|
@ -54,7 +54,7 @@ export class Mjolnir {
|
|||
private localpart: string;
|
||||
private currentState: string = STATE_NOT_STARTED;
|
||||
private protections: IProtection[] = [];
|
||||
private spamRedactionQueue = new AutomaticRedactionQueue();
|
||||
private unlistedUserRedactionQueue = new UnlistedUserRedactionQueue();
|
||||
private eventRedactionQueue = new EventRedactionQueue();
|
||||
private automaticRedactionReasons: MatrixGlob[] = [];
|
||||
private protectedJoinedRoomIds: string[] = [];
|
||||
|
@ -140,8 +140,8 @@ export class Mjolnir {
|
|||
return this.protections;
|
||||
}
|
||||
|
||||
public get redactionHandler(): AutomaticRedactionQueue {
|
||||
return this.spamRedactionQueue;
|
||||
public get unlistedUserRedactionHandler(): UnlistedUserRedactionQueue {
|
||||
return this.unlistedUserRedactionQueue;
|
||||
}
|
||||
|
||||
public get automaticRedactGlobs(): MatrixGlob[] {
|
||||
|
@ -581,7 +581,7 @@ export class Mjolnir {
|
|||
|
||||
// Run the event handlers - we always run this after protections so that the protections
|
||||
// can flag the event for redaction.
|
||||
await this.spamRedactionQueue.handleEvent(roomId, event, this.client);
|
||||
await this.unlistedUserRedactionHandler.handleEvent(roomId, event, this.client);
|
||||
|
||||
if (event['type'] === 'm.room.power_levels' && event['state_key'] === '') {
|
||||
// power levels were updated - recheck permissions
|
||||
|
@ -667,9 +667,6 @@ export class Mjolnir {
|
|||
});
|
||||
}
|
||||
|
||||
// This naming is horrible and clashes with the other redaction queue which isn't
|
||||
// really the same thing. The old one is more about an ongoing user who we haven't
|
||||
// banned, whereas this one is about redaction of users who aren't active.
|
||||
public queueRedactUserMessagesIn(userId: string, roomId: string) {
|
||||
this.eventRedactionQueue.add(new RedactUserInRoom(userId, roomId));
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ export class BasicFlooding implements IProtection {
|
|||
}
|
||||
|
||||
if (this.recentlyBanned.includes(event['sender'])) return; // already handled (will be redacted)
|
||||
mjolnir.redactionHandler.addUser(event['sender']);
|
||||
mjolnir.unlistedUserRedactionHandler.addUser(event['sender']);
|
||||
this.recentlyBanned.push(event['sender']); // flag to reduce spam
|
||||
|
||||
// Redact all the things the user said too
|
||||
|
|
|
@ -59,7 +59,7 @@ export class FirstMessageIsImage implements IProtection {
|
|||
}
|
||||
|
||||
if (this.recentlyBanned.includes(event['sender'])) return; // already handled (will be redacted)
|
||||
mjolnir.redactionHandler.addUser(event['sender']);
|
||||
mjolnir.unlistedUserRedactionHandler.addUser(event['sender']);
|
||||
this.recentlyBanned.push(event['sender']); // flag to reduce spam
|
||||
|
||||
// Redact the event
|
||||
|
|
|
@ -13,15 +13,15 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
//// NOTE: This is a queue of users whose events should be redacted
|
||||
////////// Not a queue of events to be redacted.
|
||||
////////// This is also unrelated to the AutomaticRedactionReasons.
|
||||
////////// It is as of writing only used by the flood/spam protections.
|
||||
import { extractRequestError, LogLevel, LogService, MatrixClient, Permalinks } from "matrix-bot-sdk";
|
||||
import { logMessage } from "../LogProxy";
|
||||
import config from "../config";
|
||||
|
||||
export class AutomaticRedactionQueue {
|
||||
/**
|
||||
* This is used to redact new events from users who are not banned from a watched list, but have been flagged
|
||||
* for redaction by the flooding or image protection.
|
||||
*/
|
||||
export class UnlistedUserRedactionQueue {
|
||||
private usersToRedact: Set<string> = new Set<string>();
|
||||
|
||||
constructor() {
|
Loading…
Reference in New Issue
Block a user