From fa3bce12d6052c390a9a95b0b070c858984e1807 Mon Sep 17 00:00:00 2001 From: gnuxie Date: Thu, 20 Mar 2025 12:25:30 +0000 Subject: [PATCH] Include policy entity in the takedown audit log policy info. --- src/protections/RoomTakedown/SqliteRoomAuditLog.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/protections/RoomTakedown/SqliteRoomAuditLog.ts b/src/protections/RoomTakedown/SqliteRoomAuditLog.ts index a8a682d4..7b8a12e1 100644 --- a/src/protections/RoomTakedown/SqliteRoomAuditLog.ts +++ b/src/protections/RoomTakedown/SqliteRoomAuditLog.ts @@ -35,16 +35,13 @@ const log = new Logger("SqliteRoomAuditLog"); // check with the server rather than check the audit log. // Incase rooms were unbanned. -// FIXME: The entity should really be included in the policy info mare... -// This will be important when the rule targets users and servers and -// not just rooms. - const SchemaText = [ ` CREATE TABLE policy_info ( policy_id TEXT PRIMARY KEY NOT NULL, sender_user_id TEXT NOT NULL, - room_id TEXT NOT NULL, + entity TEXT NOT NULL, + policy_room_id TEXT NOT NULL, state_key TEXT NOT NULL, type TEXT NOT NULL, recommendation TEXT NOT NULL @@ -122,8 +119,8 @@ export class SqliteRoomAuditLog } try { const policyInfoStatement = this.db.prepare( - `REPLACE INTO policy_info (policy_id, sender_user_id, room_id, state_key, type, recommendation) - VALUES (?, ?, ?, ?, ?, ?)` + `REPLACE INTO policy_info (policy_id, sender_user_id, policy_room_id, entity, state_key, type, recommendation) + VALUES (?, ?, ?, ?, ?, ?, ?)` ); const takedownStatement = this.db .prepare( @@ -138,6 +135,7 @@ export class SqliteRoomAuditLog policy.sourceEvent.event_id, policy.sourceEvent.sender, policy.sourceEvent.room_id, + policy.entity, policy.sourceEvent.state_key, policy.sourceEvent.type, policy.recommendation,