Skip to content

Commit 2f6f945

Browse files
authored
Prompt to watch policy rooms on replacement (#955)
Part of the-draupnir-project/planning#48 * Wire up prompt listener to prompt meow! * Show differences in powered users and creators between rooms. Upgraded policy rooms. * Scan for replaced policy rooms on protection enable. * Report errors with replacement process to management room. * Comment clarity. * Update MPS and MPS-for-interface-adaptor to support PR. * Note about why we want to prompt on upgrade.
1 parent 3e246ec commit 2f6f945

File tree

5 files changed

+465
-11
lines changed

5 files changed

+465
-11
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"@sinclair/typebox": "0.34.13",
5454
"@the-draupnir-project/interface-manager": "4.2.5",
5555
"@the-draupnir-project/matrix-basic-types": "1.4.0",
56-
"@the-draupnir-project/mps-interface-adaptor": "0.5.0",
56+
"@the-draupnir-project/mps-interface-adaptor": "0.5.1",
5757
"better-sqlite3": "^9.4.3",
5858
"body-parser": "^1.20.2",
5959
"config": "^3.3.9",
@@ -63,7 +63,7 @@
6363
"jsdom": "^24.0.0",
6464
"matrix-appservice-bridge": "^10.3.1",
6565
"matrix-bot-sdk": "npm:@vector-im/matrix-bot-sdk@^0.7.1-element.6",
66-
"matrix-protection-suite": "npm:@gnuxie/matrix-protection-suite@3.12.0",
66+
"matrix-protection-suite": "npm:@gnuxie/matrix-protection-suite@3.13.0",
6767
"matrix-protection-suite-for-matrix-bot-sdk": "npm:@gnuxie/[email protected]",
6868
"pg": "^8.8.0",
6969
"yaml": "^2.3.2"

src/protections/BanPropagation.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ const log = new Logger("BanPropagationProtection");
6262
const BAN_PROPAGATION_PROMPT_LISTENER =
6363
"ge.applied-langua.ge.draupnir.ban_propagation";
6464

65-
// FIXME: https://github.com/the-draupnir-project/Draupnir/issues/160
6665
function makePolicyRoomReactionReferenceMap(
6766
rooms: MatrixRoomID[]
6867
): Map<string, string> {

src/protections/ProtectedRooms/RoomsSetBehaviourProtection.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { ProtectedJoinedRooms } from "./ProtectJoinedRooms";
2121
import { UnprotectPartedRooms } from "./UnprotectPartedRooms";
2222
import { StringRoomID } from "@the-draupnir-project/matrix-basic-types";
2323
import { ProtectReplacementRooms } from "./ProtectReplacementRooms";
24+
import { WatchReplacementPolicyRooms } from "./WatchReplacementPolicyRooms";
2425

2526
export type RoomsSetBehaviourCapabailities = Record<string, never>;
2627
export type RoomsSetBehaviourSettings = UnknownConfig;
@@ -54,6 +55,17 @@ export class RoomsSetBehaviour
5455
this.draupnir.clientPlatform.toRoomMessageSender(),
5556
this.protectedRoomsSet.protectedRoomsManager
5657
);
58+
private readonly watchReplacementPolicyRooms =
59+
new WatchReplacementPolicyRooms(
60+
this.draupnir.managementRoomID,
61+
this.draupnir.clientPlatform.toRoomJoiner(),
62+
this.draupnir.clientPlatform.toRoomMessageSender(),
63+
this.draupnir.clientPlatform.toRoomReactionSender(),
64+
this.draupnir.protectedRoomsSet.watchedPolicyRooms,
65+
this.draupnir.roomStateManager,
66+
this.draupnir.policyRoomManager,
67+
this.draupnir.reactionHandler
68+
);
5769
public constructor(
5870
description: RoomsSetBehaviourDescription,
5971
capabilities: RoomsSetBehaviourCapabailities,
@@ -64,6 +76,7 @@ export class RoomsSetBehaviour
6476
if (this.draupnir.config.protectAllJoinedRooms) {
6577
void this.protectJoinedRooms.syncProtectedRooms();
6678
}
79+
void this.watchReplacementPolicyRooms.syncTombstonedPolicyRooms();
6780
}
6881

6982
public handleMembershipChange(
@@ -93,8 +106,13 @@ export class RoomsSetBehaviour
93106
changes: StateChange[]
94107
): Promise<Result<void>> {
95108
this.protectReplacementRooms.handleRoomStateChange(changes);
109+
this.watchReplacementPolicyRooms.handleRoomStateChange(changes);
96110
return Promise.resolve(Ok(undefined));
97111
}
112+
113+
public handleProtectionDisable(): void {
114+
this.watchReplacementPolicyRooms.unregisterListeners();
115+
}
98116
}
99117

100118
describeProtection<RoomsSetBehaviourCapabailities, Draupnir>({

0 commit comments

Comments
 (0)