Skip to content

Commit

Permalink
Update for MPS 0.17.1. (#347)
Browse files Browse the repository at this point in the history
* Update for MPS 0.17.1.

Part of #333
And #345

Fixes #337

* Add loggableConfigTracker to Draupnir.

Part of #217.
I don't think this is right yet.
  • Loading branch information
Gnuxie authored Apr 16, 2024
1 parent e634c3c commit ae86e17
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 20 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
"js-yaml": "^4.1.0",
"jsdom": "^24.0.0",
"matrix-appservice-bridge": "^9.0.1",
"matrix-protection-suite": "npm:@gnuxie/matrix-protection-suite@0.16.0",
"matrix-protection-suite-for-matrix-bot-sdk": "npm:@gnuxie/matrix-protection-suite-for-matrix-bot-sdk@0.16.1",
"matrix-protection-suite": "npm:@gnuxie/matrix-protection-suite@0.17.1",
"matrix-protection-suite-for-matrix-bot-sdk": "npm:@gnuxie/matrix-protection-suite-for-matrix-bot-sdk@0.17.1",
"parse-duration": "^1.0.2",
"pg": "^8.8.0",
"shell-quote": "^1.7.3",
Expand Down
9 changes: 6 additions & 3 deletions src/Draupnir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ limitations under the License.
* are NOT distributed, contributed, committed, or licensed under the Apache License.
*/

import { ActionResult, Client, ClientPlatform, ClientRooms, EventReport, Logger, MatrixRoomID, MatrixRoomReference, Membership, MembershipEvent, Ok, PolicyRoomManager, ProtectedRoomsSet, RoomEvent, RoomMembershipManager, RoomMessage, RoomStateManager, StringRoomID, StringUserID, Task, TextMessageContent, Value, isError, isStringRoomAlias, isStringRoomID, serverName, userLocalpart } from "matrix-protection-suite";
import { ActionResult, Client, ClientPlatform, ClientRooms, EventReport, LoggableConfigTracker, Logger, MatrixRoomID, MatrixRoomReference, Membership, MembershipEvent, Ok, PolicyRoomManager, ProtectedRoomsSet, RoomEvent, RoomMembershipManager, RoomMessage, RoomStateManager, StringRoomID, StringUserID, Task, TextMessageContent, Value, isError, isStringRoomAlias, isStringRoomID, serverName, userLocalpart } from "matrix-protection-suite";
import { UnlistedUserRedactionQueue } from "./queues/UnlistedUserRedactionQueue";
import { findCommandTable } from "./commands/interface-manager/InterfaceCommand";
import { ThrottlingQueue } from "./queues/ThrottlingQueue";
Expand Down Expand Up @@ -94,7 +94,8 @@ export class Draupnir implements Client {
public readonly roomStateManager: RoomStateManager,
public readonly policyRoomManager: PolicyRoomManager,
public readonly roomMembershipManager: RoomMembershipManager,
public readonly synapseAdminClient?: SynapseAdminClient
public readonly loggableConfigTracker: LoggableConfigTracker,
public readonly synapseAdminClient?: SynapseAdminClient,
) {
this.managementRoomID = this.managementRoom.toRoomIDOrAlias();
this.managementRoomOutput = new ManagementRoomOutput(
Expand Down Expand Up @@ -138,7 +139,8 @@ export class Draupnir implements Client {
roomStateManager: RoomStateManager,
policyRoomManager: PolicyRoomManager,
roomMembershipManager: RoomMembershipManager,
config: IConfig
config: IConfig,
loggableConfigTracker: LoggableConfigTracker
): Promise<ActionResult<Draupnir>> {
const draupnir = new Draupnir(
client,
Expand All @@ -151,6 +153,7 @@ export class Draupnir implements Client {
roomStateManager,
policyRoomManager,
roomMembershipManager,
loggableConfigTracker,
new SynapseAdminClient(
client,
clientUserID
Expand Down
9 changes: 6 additions & 3 deletions src/draupnirfactory/DraupnirFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* All rights reserved.
*/

import { ActionResult, ClientsInRoomMap, MatrixRoomID, StringUserID, isError } from "matrix-protection-suite";
import { ActionResult, ClientsInRoomMap, MatrixRoomID, StandardLoggableConfigTracker, StringUserID, isError } from "matrix-protection-suite";
import { Draupnir } from "../Draupnir";
import { ClientCapabilityFactory, ClientForUserID, RoomStateManagerFactory, joinedRoomsSafe } from "matrix-protection-suite-for-matrix-bot-sdk";
import { IConfig } from "../config";
Expand Down Expand Up @@ -32,6 +32,7 @@ export class DraupnirFactory {
return clientRooms;
}
const clientPlatform = this.clientCapabilityFactory.makeClientPlatform(clientUserID, client);
const configLogTracker = new StandardLoggableConfigTracker();
const protectedRoomsSet = await makeProtectedRoomsSet(
managementRoom,
roomStateManager,
Expand All @@ -40,7 +41,8 @@ export class DraupnirFactory {
client,
clientPlatform,
clientUserID,
config
config,
configLogTracker
);
if (isError(protectedRoomsSet)) {
return protectedRoomsSet;
Expand All @@ -55,7 +57,8 @@ export class DraupnirFactory {
roomStateManager,
policyRoomManager,
roomMembershipManager,
config
config,
configLogTracker
);
}
}
10 changes: 7 additions & 3 deletions src/draupnirfactory/DraupnirProtectedRoomsSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ limitations under the License.
* are NOT distributed, contributed, committed, or licensed under the Apache License.
*/

import { ActionResult, ClientPlatform, Logger, MJOLNIR_PROTECTED_ROOMS_EVENT_TYPE, MJOLNIR_WATCHED_POLICY_ROOMS_EVENT_TYPE, MatrixRoomID, MissingProtectionCB, MjolnirEnabledProtectionsEvent, MjolnirEnabledProtectionsEventType, MjolnirPolicyRoomsConfig, MjolnirProtectedRoomsConfig, MjolnirProtectedRoomsEvent, MjolnirProtectionSettingsEventType, MjolnirProtectionsConfig, MjolnirWatchedPolicyRoomsEvent, Ok, PolicyListConfig, PolicyRoomManager, ProtectedRoomsConfig, ProtectedRoomsSet, ProtectionsManager, RoomJoiner, RoomMembershipManager, RoomStateManager, SetMembership, SetRoomState, StandardProtectedRoomsSet, StandardProtectionsManager, StandardSetMembership, StandardSetRoomState, StringUserID, isError } from "matrix-protection-suite";
import { ActionResult, ClientPlatform, LoggableConfigTracker, Logger, MJOLNIR_PROTECTED_ROOMS_EVENT_TYPE, MJOLNIR_WATCHED_POLICY_ROOMS_EVENT_TYPE, MatrixRoomID, MissingProtectionCB, MjolnirEnabledProtectionsEvent, MjolnirEnabledProtectionsEventType, MjolnirPolicyRoomsConfig, MjolnirProtectedRoomsConfig, MjolnirProtectedRoomsEvent, MjolnirProtectionSettingsEventType, MjolnirProtectionsConfig, MjolnirWatchedPolicyRoomsEvent, Ok, PolicyListConfig, PolicyRoomManager, ProtectedRoomsConfig, ProtectedRoomsSet, ProtectionsManager, RoomJoiner, RoomMembershipManager, RoomStateManager, SetMembership, SetRoomState, StandardProtectedRoomsSet, StandardProtectionsManager, StandardSetMembership, StandardSetRoomState, StringUserID, isError } from "matrix-protection-suite";
import { BotSDKMatrixAccountData, BotSDKMatrixStateData, MatrixSendClient } from "matrix-protection-suite-for-matrix-bot-sdk";
import { DefaultEnabledProtectionsMigration } from "../protections/DefaultEnabledProtectionsMigration";
import '../protections/DraupnirProtectionsIndex';
Expand Down Expand Up @@ -98,7 +98,8 @@ async function makeProtectionsManager(
client: MatrixSendClient,
roomStateManager: RoomStateManager,
managementRoom: MatrixRoomID,
config: IConfig
config: IConfig,
loggableConfigTracker: LoggableConfigTracker
): Promise<ActionResult<ProtectionsManager>> {
const result = await roomStateManager.getRoomStateRevisionIssuer(
managementRoom
Expand All @@ -112,6 +113,7 @@ async function makeProtectionsManager(
MjolnirEnabledProtectionsEvent,
client
),
loggableConfigTracker,
{
migrationHandler: DefaultEnabledProtectionsMigration,
missingProtectionCB: makeMissingProtectionCB()
Expand Down Expand Up @@ -146,6 +148,7 @@ export async function makeProtectedRoomsSet(
clientPlatform: ClientPlatform,
userID: StringUserID,
config: IConfig,
loggableConfigTracker: LoggableConfigTracker,
): Promise<ActionResult<ProtectedRoomsSet>> {
const protectedRoomsConfig = await makeProtectedRoomsConfig(client, clientPlatform.toRoomJoiner())
if (isError(protectedRoomsConfig)) {
Expand Down Expand Up @@ -173,7 +176,8 @@ export async function makeProtectedRoomsSet(
client,
roomStateManager,
managementRoom,
config
config,
loggableConfigTracker
);
if (isError(protectionsConfig)) {
return protectionsConfig;
Expand Down
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2505,15 +2505,15 @@ matrix-appservice@^2.0.0:
request-promise "^4.2.6"
sanitize-html "^2.8.0"

"matrix-protection-suite-for-matrix-bot-sdk@npm:@gnuxie/matrix-protection-suite-for-matrix-bot-sdk@0.16.1":
version "0.16.1"
resolved "https://registry.yarnpkg.com/@gnuxie/matrix-protection-suite-for-matrix-bot-sdk/-/matrix-protection-suite-for-matrix-bot-sdk-0.16.1.tgz#322d6cb88cb158140f432e1f853a69e8697cd6a5"
integrity sha512-fipZknx+QNuwNHV+er6LWdnUJ8/6NhuIpqP9O8zdMVC8Wn+/vNcAzTKCO3k9ulDNYtTgA8M+dyOlg0nOJVCJAQ==

"matrix-protection-suite@npm:@gnuxie/matrix-protection-suite@0.16.0":
version "0.16.0"
resolved "https://registry.yarnpkg.com/@gnuxie/matrix-protection-suite/-/matrix-protection-suite-0.16.0.tgz#380367f76721373e13cc04399ddffa0b9b1ee9c0"
integrity sha512-XNAaECsv3CUYZN2mBiwVrG+qOs+KP0NDIw353/KtZFOAoAKwCFltXpPoQe/TT+Lc0eSVxfKtW6+rofWBccjfVQ==
"matrix-protection-suite-for-matrix-bot-sdk@npm:@gnuxie/matrix-protection-suite-for-matrix-bot-sdk@0.17.1":
version "0.17.1"
resolved "https://registry.yarnpkg.com/@gnuxie/matrix-protection-suite-for-matrix-bot-sdk/-/matrix-protection-suite-for-matrix-bot-sdk-0.17.1.tgz#925363e0282879156c9f9b7673a8e6acd78e1a71"
integrity sha512-8vIu51ZLlVDUqRgz6K7bQMSjp/DEY+q1AO2mqvO/cSnHly/XKaflszwxN9zySAj6JjFXgPt+z1WkqV5omWE9NA==

"matrix-protection-suite@npm:@gnuxie/matrix-protection-suite@0.17.1":
version "0.17.1"
resolved "https://registry.yarnpkg.com/@gnuxie/matrix-protection-suite/-/matrix-protection-suite-0.17.1.tgz#7c4330a029461652d61d89ba5461c99324cfc3a1"
integrity sha512-3p9OqHf1JKymD1igceA5qy008Bqf9hSXC6mhPlLPqL7JGLFyE5FHa3eJcJJorZAfq54TH+KVmgpL0Es+E/wxfQ==
dependencies:
await-lock "^2.2.2"
crypto-js "^4.1.1"
Expand Down

0 comments on commit ae86e17

Please sign in to comment.