Skip to content

Commit

Permalink
Merge pull request #523 from matrix-org/hs/update-bot-sdk-to-support-…
Browse files Browse the repository at this point in the history
…authed-media

Support authenticated media (by updating bot-sdk / matrix-appservice-bridge)
  • Loading branch information
Half-Shot authored Sep 19, 2024
2 parents 1c5b49d + b1e2a3e commit 5f4178f
Show file tree
Hide file tree
Showing 80 changed files with 392 additions and 260 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/mjolnir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Specifically use node 18 like in the readme.
uses: actions/setup-node@v3
with:
node-version: '18'
node-version: '20'
- run: yarn install
- run: yarn build
- run: yarn lint
Expand All @@ -32,7 +32,7 @@ jobs:
- name: Specifically use node 18 like in the readme.
uses: actions/setup-node@v3
with:
node-version: '18'
node-version: '20'
- run: yarn install
- run: yarn test
integration:
Expand All @@ -43,7 +43,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
node-version: '20'
- name: Fetch and build mx-tester (cached across runs)
uses: baptiste0928/cargo-install@v1
with:
Expand All @@ -65,7 +65,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
node-version: '20'
- name: Fetch and build mx-tester (cached across runs)
uses: baptiste0928/cargo-install@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# We can't use alpine anymore because crypto has rust deps.
FROM node:18-slim
FROM node:20-slim
COPY . /tmp/src
RUN cd /tmp/src \
&& yarn install \
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
"humanize-duration-ts": "^2.1.1",
"js-yaml": "^4.1.0",
"jsdom": "^16.6.0",
"matrix-appservice-bridge": "8.1.2",
"@vector-im/matrix-bot-sdk": "^0.7.1-element.6",
"matrix-appservice-bridge": "10.3.1",
"nsfwjs": "^4.1.0",
"parse-duration": "^1.0.2",
"pg": "^8.8.0",
Expand All @@ -66,6 +67,6 @@
"yaml": "^2.2.2"
},
"engines": {
"node": ">=18.0.0"
"node": ">=20.0.0"
}
}
2 changes: 1 addition & 1 deletion src/ManagementRoomOutput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import * as Sentry from "@sentry/node";
import { extractRequestError, LogLevel, LogService, MessageType, Permalinks, TextualMessageEventContent, UserID } from "matrix-bot-sdk";
import { extractRequestError, LogLevel, LogService, MessageType, Permalinks, TextualMessageEventContent, UserID } from "@vector-im/matrix-bot-sdk";
import { IConfig } from "./config";
import { MatrixSendClient } from "./MatrixEmitter";
import { htmlEscape } from "./utils";
Expand Down
2 changes: 1 addition & 1 deletion src/MatrixEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import EventEmitter from "events";
import { MatrixClient } from "matrix-bot-sdk";
import { MatrixClient } from "@vector-im/matrix-bot-sdk";

/**
* This is an interface created in order to keep the event listener
Expand Down
2 changes: 1 addition & 1 deletion src/Mjolnir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
LogLevel,
LogService,
MembershipEvent,
} from "matrix-bot-sdk";
} from "@vector-im/matrix-bot-sdk";

import { ALL_RULE_TYPES as ALL_BAN_LIST_RULE_TYPES } from "./models/ListRule";
import { COMMAND_PREFIX, handleCommand } from "./commands/CommandHandler";
Expand Down
2 changes: 1 addition & 1 deletion src/ProtectedRoomsConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import AwaitLock from 'await-lock';
import { extractRequestError, LogService, Permalinks } from "matrix-bot-sdk";
import { extractRequestError, LogService, Permalinks } from "@vector-im/matrix-bot-sdk";
import { IConfig } from "./config";
import { MatrixSendClient } from './MatrixEmitter';
const PROTECTED_ROOMS_EVENT_TYPE = "org.matrix.mjolnir.protected_rooms";
Expand Down
2 changes: 1 addition & 1 deletion src/ProtectedRoomsSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { LogLevel, LogService, MatrixGlob, Permalinks, UserID } from "matrix-bot-sdk";
import { LogLevel, LogService, MatrixGlob, Permalinks, UserID } from "@vector-im/matrix-bot-sdk";
import { IConfig } from "./config";
import ErrorCache, { ERROR_KIND_FATAL, ERROR_KIND_PERMISSION } from "./ErrorCache";
import ManagementRoomOutput from "./ManagementRoomOutput";
Expand Down
2 changes: 1 addition & 1 deletion src/appservice/AccessControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.
import { Bridge } from "matrix-appservice-bridge";
import AccessControlUnit, { EntityAccess } from "../models/AccessControlUnit";
import PolicyList from "../models/PolicyList";
import { Permalinks } from "matrix-bot-sdk";
import { Permalinks } from "@vector-im/matrix-bot-sdk";

/**
* Utility to manage which users have access to the application service,
Expand Down
1 change: 1 addition & 0 deletions src/appservice/AppService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export class MjolnirAppService {
onEvent: () => {throw new Error("Mjolnir uninitialized")},
},
suppressEcho: false,
disableStores: true,
});
await bridge.initialise();
const accessControlListId = await bridge.getBot().getClient().resolveRoom(config.accessControlList);
Expand Down
2 changes: 1 addition & 1 deletion src/appservice/MjolnirManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Request, WeakEvent, BridgeContext, Bridge, Intent, Logger } from "matri
import { getProvisionedMjolnirConfig } from "../config";
import { IConfig as IAppserviceConfig } from "./config/config";
import PolicyList from "../models/PolicyList";
import { Permalinks, MatrixClient } from "matrix-bot-sdk";
import { Permalinks, MatrixClient } from "@vector-im/matrix-bot-sdk";
import { DataStore } from "./datastore";
import { AccessControl } from "./AccessControl";
import { Access } from "../models/AccessControlUnit";
Expand Down
2 changes: 1 addition & 1 deletion src/commands/AddRemoveProtectedRoomsCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import { Mjolnir } from "../Mjolnir";
import { extractRequestError, LogLevel, LogService } from "matrix-bot-sdk";
import { extractRequestError, LogLevel, LogService } from "@vector-im/matrix-bot-sdk";

// !mjolnir rooms add <room alias/ID>
export async function execAddProtectedRoom(roomId: string, event: any, mjolnir: Mjolnir, parts: string[]) {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/AddRemoveRoomFromDirectoryCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import { Mjolnir } from "../Mjolnir";
import { RichReply } from "matrix-bot-sdk";
import { RichReply } from "@vector-im/matrix-bot-sdk";

async function addRemoveFromDirectory(inRoomId: string, event: any, mjolnir: Mjolnir, roomRef: string, visibility: "public" | "private") {
const isAdmin = await mjolnir.isSynapseAdmin();
Expand Down
2 changes: 1 addition & 1 deletion src/commands/AliasCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import { Mjolnir } from "../Mjolnir";
import { RichReply } from "matrix-bot-sdk";
import { RichReply } from "@vector-im/matrix-bot-sdk";
import { htmlEscape } from "../utils";

// !mjolnir move <alias> <new room ID>
Expand Down
2 changes: 1 addition & 1 deletion src/commands/CommandHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { Mjolnir } from "../Mjolnir";
import { execStatusCommand } from "./StatusCommand";
import { execBanCommand, execUnbanCommand } from "./UnbanBanCommand";
import { execDumpRulesCommand, execRulesMatchingCommand } from "./DumpRulesCommand";
import { extractRequestError, LogService, RichReply } from "matrix-bot-sdk";
import { extractRequestError, LogService, RichReply } from "@vector-im/matrix-bot-sdk";
import { htmlEscape } from "../utils";
import { execSyncCommand } from "./SyncCommand";
import { execPermissionCheckCommand } from "./PermissionCheckCommand";
Expand Down
2 changes: 1 addition & 1 deletion src/commands/CreateBanListCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

import { Mjolnir } from "../Mjolnir";
import PolicyList from "../models/PolicyList";
import { Permalinks, RichReply } from "matrix-bot-sdk";
import { Permalinks, RichReply } from "@vector-im/matrix-bot-sdk";

// !mjolnir list create <shortcode> <alias localpart>
export async function execCreateListCommand(roomId: string, event: any, mjolnir: Mjolnir, parts: string[]) {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/DeactivateCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import { Mjolnir } from "../Mjolnir";
import { RichReply } from "matrix-bot-sdk";
import { RichReply } from "@vector-im/matrix-bot-sdk";

// !mjolnir deactivate <user ID>
export async function execDeactivateCommand(roomId: string, event: any, mjolnir: Mjolnir, parts: string[]) {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/DumpRulesCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { RichReply } from "matrix-bot-sdk";
import { RichReply } from "@vector-im/matrix-bot-sdk";
import { Mjolnir } from "../Mjolnir";
import { EntityType } from "../models/ListRule";
import { htmlEscape } from "../utils";
Expand Down
2 changes: 1 addition & 1 deletion src/commands/ImportCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import { Mjolnir } from "../Mjolnir";
import { RichReply } from "matrix-bot-sdk";
import { RichReply } from "@vector-im/matrix-bot-sdk";
import { EntityType } from "../models/ListRule";
import PolicyList from "../models/PolicyList";

Expand Down
2 changes: 1 addition & 1 deletion src/commands/KickCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import { Mjolnir } from "../Mjolnir";
import { LogLevel, MatrixGlob, RichReply } from "matrix-bot-sdk";
import { LogLevel, MatrixGlob, RichReply } from "@vector-im/matrix-bot-sdk";

// !mjolnir kick <user|filter> [room] [reason]
export async function execKickCommand(roomId: string, event: any, mjolnir: Mjolnir, parts: string[]) {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/ListProtectedRoomsCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import { Mjolnir } from "../Mjolnir";
import { Permalinks, RichReply } from "matrix-bot-sdk";
import { Permalinks, RichReply } from "@vector-im/matrix-bot-sdk";

// !mjolnir rooms
export async function execListProtectedRooms(roomId: string, event: any, mjolnir: Mjolnir) {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/MakeRoomAdminCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import { Mjolnir } from "../Mjolnir";
import { RichReply } from "matrix-bot-sdk";
import { RichReply } from "@vector-im/matrix-bot-sdk";

// !mjolnir make admin <room> [<user ID>]
export async function execMakeRoomAdminCommand(roomId: string, event: any, mjolnir: Mjolnir, parts: string[]) {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/ProtectionsCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

import { htmlEscape } from "../utils";
import { Mjolnir } from "../Mjolnir";
import { extractRequestError, LogService, RichReply } from "matrix-bot-sdk";
import { extractRequestError, LogService, RichReply } from "@vector-im/matrix-bot-sdk";
import { isListSetting } from "../protections/ProtectionSettings";

// !mjolnir enable <protection>
Expand Down
2 changes: 1 addition & 1 deletion src/commands/RedactCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

import { Mjolnir } from "../Mjolnir";
import { redactUserMessagesIn } from "../utils";
import { Permalinks } from "matrix-bot-sdk";
import { Permalinks } from "@vector-im/matrix-bot-sdk";

// !mjolnir redact <user ID> [room alias] [limit]
export async function execRedactCommand(roomId: string, event: any, mjolnir: Mjolnir, parts: string[]) {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/SetDefaultBanListCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import { Mjolnir } from "../Mjolnir";
import { RichReply } from "matrix-bot-sdk";
import { RichReply } from "@vector-im/matrix-bot-sdk";

export const DEFAULT_LIST_EVENT_TYPE = "org.matrix.mjolnir.default_list";

Expand Down
2 changes: 1 addition & 1 deletion src/commands/SetPowerLevelCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import { Mjolnir } from "../Mjolnir";
import { extractRequestError, LogLevel, LogService } from "matrix-bot-sdk";
import { extractRequestError, LogLevel, LogService } from "@vector-im/matrix-bot-sdk";

// !mjolnir powerlevel <user ID> <level> [room]
export async function execSetPowerLevelCommand(roomId: string, event: any, mjolnir: Mjolnir, parts: string[]) {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/SetupDecentralizedReportingCommand.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Mjolnir } from "../Mjolnir";
import { LogLevel } from "matrix-bot-sdk";
import { LogLevel } from "@vector-im/matrix-bot-sdk";

const EVENT_MODERATED_BY = "org.matrix.msc3215.room.moderation.moderated_by";
const EVENT_MODERATOR_OF = "org.matrix.msc3215.room.moderation.moderator_of";
Expand Down
2 changes: 1 addition & 1 deletion src/commands/ShutdownRoomCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import { Mjolnir } from "../Mjolnir";
import { RichReply } from "matrix-bot-sdk";
import { RichReply } from "@vector-im/matrix-bot-sdk";

// !mjolnir shutdown room <room> [<message>]
export async function execShutdownRoomCommand(roomId: string, event: any, mjolnir: Mjolnir, parts: string[]) {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/SinceCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import { Mjolnir } from "../Mjolnir";
import { LogLevel, LogService, RichReply } from "matrix-bot-sdk";
import { LogLevel, LogService, RichReply } from "@vector-im/matrix-bot-sdk";
import { htmlEscape, parseDuration } from "../utils";
import { ParseEntry } from "shell-quote";
import { HumanizeDurationLanguage, HumanizeDuration } from "humanize-duration-ts";
Expand Down
2 changes: 1 addition & 1 deletion src/commands/StatusCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import { Mjolnir, STATE_CHECKING_PERMISSIONS, STATE_NOT_STARTED, STATE_RUNNING, STATE_SYNCING } from "../Mjolnir";
import { RichReply } from "matrix-bot-sdk";
import { RichReply } from "@vector-im/matrix-bot-sdk";
import { htmlEscape, parseDuration } from "../utils";
import { HumanizeDurationLanguage, HumanizeDuration } from "humanize-duration-ts";
import PolicyList from "../models/PolicyList";
Expand Down
2 changes: 1 addition & 1 deletion src/commands/SuspendCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import {Mjolnir} from "../Mjolnir";
import {RichReply} from "matrix-bot-sdk";
import {RichReply} from "@vector-im/matrix-bot-sdk";

export async function execSuspendCommand(roomId: string, event: any, mjolnir: Mjolnir, parts: string[]) {
const target = parts[2];
Expand Down
2 changes: 1 addition & 1 deletion src/commands/UnbanBanCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

import { Mjolnir } from "../Mjolnir";
import PolicyList from "../models/PolicyList";
import { extractRequestError, LogLevel, LogService, MatrixGlob, RichReply } from "matrix-bot-sdk";
import { extractRequestError, LogLevel, LogService, MatrixGlob, RichReply } from "@vector-im/matrix-bot-sdk";
import { RULE_ROOM, RULE_SERVER, RULE_USER, USER_RULE_TYPES } from "../models/ListRule";
import { DEFAULT_LIST_EVENT_TYPE } from "./SetDefaultBanListCommand";

Expand Down
2 changes: 1 addition & 1 deletion src/commands/UnsuspendCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import {Mjolnir} from "../Mjolnir";
import {RichReply} from "matrix-bot-sdk";
import {RichReply} from "@vector-im/matrix-bot-sdk";

export async function execUnsuspendCommand(roomId: string, event: any, mjolnir: Mjolnir, parts: string[]) {
const target = parts[2];
Expand Down
2 changes: 1 addition & 1 deletion src/commands/WatchUnwatchCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import { Mjolnir } from "../Mjolnir";
import { Permalinks, RichReply } from "matrix-bot-sdk";
import { Permalinks, RichReply } from "@vector-im/matrix-bot-sdk";

// !mjolnir watch <room alias or ID>
export async function execWatchCommand(roomId: string, event: any, mjolnir: Mjolnir, parts: string[]) {
Expand Down
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

import * as fs from "fs";
import { load } from "js-yaml";
import { MatrixClient, LogService } from "matrix-bot-sdk";
import { MatrixClient, LogService } from "@vector-im/matrix-bot-sdk";
import Config from "config";

export interface IHealthConfig {
Expand Down
2 changes: 1 addition & 1 deletion src/health/healthz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import * as http from "http";
import { LogService } from "matrix-bot-sdk";
import { LogService } from "@vector-im/matrix-bot-sdk";
import { IConfig } from "../config";
// allowed to use the global configuration since this is only intended to be used by `src/index.ts`.

Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
PantalaimonClient,
RichConsoleLogger,
SimpleFsStorageProvider
} from "matrix-bot-sdk";
} from "@vector-im/matrix-bot-sdk";

import { read as configRead } from "./config";
import { Mjolnir } from "./Mjolnir";
Expand Down
2 changes: 1 addition & 1 deletion src/models/AccessControlUnit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

import PolicyList, { ChangeType, ListRuleChange } from "./PolicyList";
import { EntityType, ListRule, Recommendation, RULE_SERVER, RULE_USER } from "./ListRule";
import { LogService, UserID } from "matrix-bot-sdk";
import { LogService, UserID } from "@vector-im/matrix-bot-sdk";
import { ServerAcl } from "./ServerAcl";

/**
Expand Down
2 changes: 1 addition & 1 deletion src/models/ListRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { MatrixGlob } from "matrix-bot-sdk";
import { MatrixGlob } from "@vector-im/matrix-bot-sdk";

export enum EntityType {
/// `entity` is to be parsed as a glob of users IDs
Expand Down
2 changes: 1 addition & 1 deletion src/models/PolicyList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { extractRequestError, LogLevel, LogService, Permalinks, RoomCreateOptions, UserID } from "matrix-bot-sdk";
import { extractRequestError, LogLevel, LogService, Permalinks, RoomCreateOptions, UserID } from "@vector-im/matrix-bot-sdk";
import { EventEmitter } from "events";
import { ALL_RULE_TYPES, EntityType, ListRule, Recommendation, ROOM_RULE_TYPES, RULE_ROOM, RULE_SERVER, RULE_USER, SERVER_RULE_TYPES, USER_RULE_TYPES } from "./ListRule";
import { MatrixSendClient } from "../MatrixEmitter";
Expand Down
2 changes: 1 addition & 1 deletion src/models/RuleServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/
import BanList, { ChangeType, ListRuleChange } from "./PolicyList"
import * as crypto from "crypto";
import { LogService } from "matrix-bot-sdk";
import { LogService } from "@vector-im/matrix-bot-sdk";
import { EntityType, ListRule } from "./ListRule";
import PolicyList from "./PolicyList";

Expand Down
Loading

0 comments on commit 5f4178f

Please sign in to comment.