mirror of
https://github.com/the-draupnir-project/Draupnir.git
synced 2026-09-16 23:54:19 +00:00
Fix integration test fixtures now safe mode toggle controls draupnir.
This commit is contained in:
@@ -46,22 +46,12 @@ export const mochaHooks = {
|
||||
this.timeout(30000);
|
||||
const config = (this.config = configRead());
|
||||
this.managementRoomAlias = config.managementRoom;
|
||||
this.draupnir = await makeMjolnir(config);
|
||||
this.draupnir = await makeMjolnir(config, { eraseAccountData: true });
|
||||
const draupnirMatrixClient = draupnirClient();
|
||||
if (draupnirMatrixClient === null) {
|
||||
throw new TypeError(`setup code is broken`);
|
||||
}
|
||||
config.RUNTIME.client = draupnirMatrixClient;
|
||||
await Promise.all([
|
||||
this.draupnir.client.setAccountData(
|
||||
MJOLNIR_PROTECTED_ROOMS_EVENT_TYPE,
|
||||
{ rooms: [] }
|
||||
),
|
||||
this.draupnir.client.setAccountData(
|
||||
MJOLNIR_WATCHED_POLICY_ROOMS_EVENT_TYPE,
|
||||
{ references: [] }
|
||||
),
|
||||
]);
|
||||
await this.draupnir.start();
|
||||
this.apis = constructWebAPIs(this.draupnir);
|
||||
await this.apis.start();
|
||||
|
||||
@@ -21,13 +21,12 @@ import { DefaultEventDecoder, Task } from "matrix-protection-suite";
|
||||
|
||||
void (async () => {
|
||||
const config = configRead();
|
||||
const mjolnir = await makeMjolnir(
|
||||
config,
|
||||
new SqliteRoomStateBackingStore(
|
||||
const mjolnir = await makeMjolnir(config, {
|
||||
backingStore: new SqliteRoomStateBackingStore(
|
||||
path.join(config.dataPath, "room-state-backing-store.db"),
|
||||
DefaultEventDecoder
|
||||
)
|
||||
);
|
||||
),
|
||||
});
|
||||
console.info(`management room ${mjolnir.managementRoom.toPermalink()}`);
|
||||
const apis = constructWebAPIs(mjolnir);
|
||||
await draupnirClient()?.start();
|
||||
|
||||
@@ -27,6 +27,8 @@ import {
|
||||
} from "matrix-protection-suite-for-matrix-bot-sdk";
|
||||
import {
|
||||
DefaultEventDecoder,
|
||||
MJOLNIR_PROTECTED_ROOMS_EVENT_TYPE,
|
||||
MJOLNIR_WATCHED_POLICY_ROOMS_EVENT_TYPE,
|
||||
RoomStateBackingStore,
|
||||
} from "matrix-protection-suite";
|
||||
import { WebAPIs } from "../../src/webapis/WebAPIs";
|
||||
@@ -121,7 +123,10 @@ let globalSafeEmitter: SafeMatrixEmitter | undefined;
|
||||
*/
|
||||
export async function makeMjolnir(
|
||||
config: IConfig,
|
||||
backingStore?: RoomStateBackingStore
|
||||
{
|
||||
backingStore,
|
||||
eraseAccountData,
|
||||
}: { backingStore?: RoomStateBackingStore; eraseAccountData?: boolean } = {}
|
||||
): Promise<Draupnir> {
|
||||
await configureMjolnir(config);
|
||||
LogService.setLogger(new RichConsoleLogger());
|
||||
@@ -135,6 +140,14 @@ export async function makeMjolnir(
|
||||
config.pantalaimon.username,
|
||||
config.pantalaimon.password
|
||||
);
|
||||
if (eraseAccountData) {
|
||||
await Promise.all([
|
||||
client.setAccountData(MJOLNIR_PROTECTED_ROOMS_EVENT_TYPE, { rooms: [] }),
|
||||
client.setAccountData(MJOLNIR_WATCHED_POLICY_ROOMS_EVENT_TYPE, {
|
||||
references: [],
|
||||
}),
|
||||
]);
|
||||
}
|
||||
await overrideRatelimitForUser(
|
||||
config.homeserverUrl,
|
||||
await client.getUserId()
|
||||
|
||||
Reference in New Issue
Block a user