From 8d8cb0fe40e08afd9c6bcca5e2f895d8e3be142e Mon Sep 17 00:00:00 2001 From: gnuxie Date: Wed, 10 Jan 2024 19:03:12 +0000 Subject: [PATCH] Update commands for removal of MPS managerManager. --- src/commands/Ban.tsx | 4 ++-- src/commands/CreateBanListCommand.ts | 2 +- src/commands/ImportCommand.ts | 2 +- src/commands/StatusCommand.tsx | 2 +- src/commands/Unban.ts | 4 ++-- src/protections/BanPropagation.tsx | 8 ++++---- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/commands/Ban.tsx b/src/commands/Ban.tsx index 6bb06384..c0f4c1a2 100644 --- a/src/commands/Ban.tsx +++ b/src/commands/Ban.tsx @@ -43,7 +43,7 @@ export async function findPolicyRoomEditorFromRoomReference(draupnir: Draupnir, if (isError(policyRoomID)) { return policyRoomID; } - return await draupnir.managerManager.policyRoomManager.getPolicyRoomEditor(policyRoomID.ok); + return await draupnir.policyRoomManager.getPolicyRoomEditor(policyRoomID.ok); } async function ban( @@ -97,7 +97,7 @@ defineInterfaceCommand({ ), prompt: async function (this: DraupnirContext, _parameter: ParameterDescription): Promise { return { - suggestions: this.draupnir.managerManager.policyRoomManager.getEditablePolicyRoomIDs( + suggestions: this.draupnir.policyRoomManager.getEditablePolicyRoomIDs( this.draupnir.clientUserID, PolicyRuleType.User ) diff --git a/src/commands/CreateBanListCommand.ts b/src/commands/CreateBanListCommand.ts index 15e5ce59..297f33cf 100644 --- a/src/commands/CreateBanListCommand.ts +++ b/src/commands/CreateBanListCommand.ts @@ -39,7 +39,7 @@ export async function createList( alias: MatrixRoomAlias, ...reasonParts: string[] ): Promise> { - const newList = await this.draupnir.managerManager.policyRoomManager.createPolicyRoom( + const newList = await this.draupnir.policyRoomManager.createPolicyRoom( shortcode, [this.event.sender], { diff --git a/src/commands/ImportCommand.ts b/src/commands/ImportCommand.ts index b03d6ae5..5fe9fbb5 100644 --- a/src/commands/ImportCommand.ts +++ b/src/commands/ImportCommand.ts @@ -47,7 +47,7 @@ export async function importCommand( if (isError(policyRoom)) { return policyRoom; } - const policyRoomEditor = await this.draupnir.managerManager.policyRoomManager.getPolicyRoomEditor( + const policyRoomEditor = await this.draupnir.policyRoomManager.getPolicyRoomEditor( policyRoom.ok ); if (isError(policyRoomEditor)) { diff --git a/src/commands/StatusCommand.tsx b/src/commands/StatusCommand.tsx index 57156bae..a6186f9e 100644 --- a/src/commands/StatusCommand.tsx +++ b/src/commands/StatusCommand.tsx @@ -62,7 +62,7 @@ export interface StatusInfo { export async function listInfo(draupnir: Draupnir): Promise { const watchedListProfiles = draupnir.protectedRoomsSet.issuerManager.allWatchedLists; const issuerResults = await Promise.all(watchedListProfiles.map((profile) => - draupnir.managerManager.policyRoomManager.getPolicyRoomRevisionIssuer(profile.room) + draupnir.policyRoomManager.getPolicyRoomRevisionIssuer(profile.room) )); return issuerResults.map((result) => { if (isError(result)) { diff --git a/src/commands/Unban.ts b/src/commands/Unban.ts index 01d67a4f..2b932104 100644 --- a/src/commands/Unban.ts +++ b/src/commands/Unban.ts @@ -64,7 +64,7 @@ async function unban( if (isError(policyRoom)) { return policyRoom; } - const policyRoomEditor = await this.draupnir.managerManager.policyRoomManager.getPolicyRoomEditor( + const policyRoomEditor = await this.draupnir.policyRoomManager.getPolicyRoomEditor( policyRoom.ok ); if (isError(policyRoomEditor)) { @@ -120,7 +120,7 @@ defineInterfaceCommand({ ), prompt: async function (this: DraupnirContext) { return { - suggestions: this.draupnir.managerManager.policyRoomManager.getEditablePolicyRoomIDs( + suggestions: this.draupnir.policyRoomManager.getEditablePolicyRoomIDs( this.draupnir.clientUserID, PolicyRuleType.User ) diff --git a/src/protections/BanPropagation.tsx b/src/protections/BanPropagation.tsx index b61080dc..e4e16b94 100644 --- a/src/protections/BanPropagation.tsx +++ b/src/protections/BanPropagation.tsx @@ -67,7 +67,7 @@ async function promptBanPropagation( draupnir: Draupnir, change: MembershipChange, ): Promise { - const editablePolicyRoomIDs = draupnir.managerManager.policyRoomManager.getEditablePolicyRoomIDs( + const editablePolicyRoomIDs = draupnir.policyRoomManager.getEditablePolicyRoomIDs( draupnir.clientUserID, PolicyRuleType.User ); @@ -211,7 +211,7 @@ export class BanPropagationProtection extends AbstractProtection implements Drau log.error(`Could not resolve the room reference for the policy list to ban a user within ${policyRoomRef.ok.toPermalink()}`, roomID.error); return; } - const listResult = await this.draupnir.managerManager.policyRoomManager.getPolicyRoomEditor(roomID.ok) + const listResult = await this.draupnir.policyRoomManager.getPolicyRoomEditor(roomID.ok) if (isError(listResult)) { log.error(`Could not find a policy list for the policy room ${policyRoomRef.ok.toPermalink()}`, listResult.error); return; @@ -233,7 +233,7 @@ export class BanPropagationProtection extends AbstractProtection implements Drau const policyRevision = this.protectedRoomsSet.issuerManager.policyListRevisionIssuer.currentRevision; const rulesMatchingUser = policyRevision.allRulesMatchingEntity(context.target, PolicyRuleType.User, Recommendation.Ban); const listsWithRules = new Set(rulesMatchingUser.map((rule) => rule.sourceEvent.room_id)); - const editablePolicyRooms = this.draupnir.managerManager.policyRoomManager.getEditablePolicyRoomIDs(this.draupnir.clientUserID, PolicyRuleType.User); + const editablePolicyRooms = this.draupnir.policyRoomManager.getEditablePolicyRoomIDs(this.draupnir.clientUserID, PolicyRuleType.User); for (const roomIDWithPolicy of listsWithRules) { const editablePolicyRoom = editablePolicyRooms.find((room) => room.toRoomIDOrAlias() === roomIDWithPolicy); if (editablePolicyRoom === undefined) { @@ -241,7 +241,7 @@ export class BanPropagationProtection extends AbstractProtection implements Drau errors.push(new PermissionError(roomID, `${this.draupnir.clientUserID} doesn't have the power level to remove the policy banning ${context.target} within ${roomID.toPermalink()}`)); continue; } - const editorResult = await this.draupnir.managerManager.policyRoomManager.getPolicyRoomEditor(editablePolicyRoom); + const editorResult = await this.draupnir.policyRoomManager.getPolicyRoomEditor(editablePolicyRoom); if (isError(editorResult)) { errors.push(RoomActionError.fromActionError(editablePolicyRoom, editorResult.error)); continue;