Update for MPS 0.17.1. (#347)

* Update for MPS 0.17.1.

Part of https://github.com/the-draupnir-project/Draupnir/issues/333
And https://github.com/the-draupnir-project/Draupnir/issues/345

Fixes https://github.com/the-draupnir-project/Draupnir/issues/337

* Add loggableConfigTracker to Draupnir.

Part of https://github.com/the-draupnir-project/Draupnir/issues/217.
I don't think this is right yet.
This commit is contained in:
Gnuxie authored and GitHub committed 2024-04-16 12:24:17 +01:00
1 parent e634c3c502
commit ae86e173f5
5 files changed
+29 -19

No files matched your search

+2 -2
View File
@@ -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",
+6 -3
View File
@@ -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";
@@ -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(
@@ -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,
@@ -151,6 +153,7 @@ export class Draupnir implements Client {
roomStateManager,
policyRoomManager,
roomMembershipManager,
loggableConfigTracker,
new SynapseAdminClient(
client,
clientUserID
+6 -3
View File
@@ -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";
@@ -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,
@@ -40,7 +41,8 @@ export class DraupnirFactory {
client,
clientPlatform,
clientUserID,
config
config,
configLogTracker
);
if (isError(protectedRoomsSet)) {
return protectedRoomsSet;
@@ -55,7 +57,8 @@ export class DraupnirFactory {
roomStateManager,
policyRoomManager,
roomMembershipManager,
config
config,
configLogTracker
);
}
}
@@ -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';
@@ -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
@@ -112,6 +113,7 @@ async function makeProtectionsManager(
MjolnirEnabledProtectionsEvent,
client
),
loggableConfigTracker,
{
migrationHandler: DefaultEnabledProtectionsMigration,
missingProtectionCB: makeMissingProtectionCB()
@@ -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)) {
@@ -173,7 +176,8 @@ export async function makeProtectedRoomsSet(
client,
roomStateManager,
managementRoom,
config
config,
loggableConfigTracker
);
if (isError(protectionsConfig)) {
return protectionsConfig;
+8 -8
View File
@@ -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-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.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@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"