mirror of
https://github.com/the-draupnir-project/Draupnir.git
synced 2026-03-29 10:29:57 +00:00
Rigidity wrt disposing stores and protections.
This commit is contained in:
@@ -63,7 +63,7 @@
|
||||
"jsdom": "^24.0.0",
|
||||
"matrix-appservice-bridge": "^10.3.1",
|
||||
"matrix-bot-sdk": "npm:@vector-im/matrix-bot-sdk@^0.7.1-element.6",
|
||||
"matrix-protection-suite": "npm:@gnuxie/matrix-protection-suite@3.6.0",
|
||||
"matrix-protection-suite": "npm:@gnuxie/matrix-protection-suite@3.6.1",
|
||||
"matrix-protection-suite-for-matrix-bot-sdk": "npm:@gnuxie/matrix-protection-suite-for-matrix-bot-sdk@3.6.0",
|
||||
"pg": "^8.8.0",
|
||||
"yaml": "^2.3.2"
|
||||
|
||||
@@ -241,7 +241,12 @@ export class MjolnirAppService {
|
||||
dataStore,
|
||||
DefaultEventDecoder,
|
||||
registrationFilePath,
|
||||
{ roomStateBackingStore: backingStore } // we don't support any stores in appservice atm except backing store.
|
||||
{
|
||||
roomStateBackingStore: backingStore,
|
||||
dispose() {
|
||||
backingStore?.destroy();
|
||||
},
|
||||
} // we don't support any stores in appservice atm except backing store.
|
||||
);
|
||||
// The call to `start` MUST happen last. As it needs the datastore, and the mjolnir manager to be initialized before it can process events from the homeserver.
|
||||
await service.start(port);
|
||||
|
||||
@@ -15,6 +15,7 @@ export type TopLevelStores = {
|
||||
roomAuditLog?: RoomAuditLog | undefined;
|
||||
roomStateBackingStore?: SqliteRoomStateBackingStore | undefined;
|
||||
userRestrictionAuditLog?: UserRestrictionAuditLog | undefined;
|
||||
dispose(): void;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -64,5 +65,11 @@ export function makeTopLevelStores(
|
||||
roomAuditLog: SqliteRoomAuditLog.createToplevel(storagePath),
|
||||
userRestrictionAuditLog:
|
||||
SqliteUserRestrictionAuditLog.createToplevel(storagePath),
|
||||
dispose() {
|
||||
this.roomStateBackingStore?.destroy();
|
||||
this.hashStore?.destroy();
|
||||
this.roomAuditLog?.destroy();
|
||||
this.userRestrictionAuditLog?.destroy();
|
||||
},
|
||||
} satisfies TopLevelStores);
|
||||
}
|
||||
|
||||
@@ -105,14 +105,7 @@ export const mochaHooks = {
|
||||
this.timeout(10000);
|
||||
await this.toggle?.stopEverything();
|
||||
draupnirClient()?.stop();
|
||||
this.stores?.roomStateBackingStore?.destroy();
|
||||
this.stores?.roomAuditLog?.destroy();
|
||||
// We forgot to add a destroy method in the interface in MPS
|
||||
// and we'll probably need to wait until the next release to remove this.
|
||||
if (this.stores?.hashStore instanceof SqliteHashReversalStore) {
|
||||
this.stores.hashStore.destroy();
|
||||
}
|
||||
// remove alias from management room and leave it.
|
||||
this.stores?.dispose();
|
||||
if (this.draupnir !== undefined) {
|
||||
await Promise.all([
|
||||
this.draupnir.client.setAccountData(
|
||||
@@ -125,6 +118,7 @@ export const mochaHooks = {
|
||||
),
|
||||
]);
|
||||
const client = draupnirClient();
|
||||
// remove alias from management room and leave it.
|
||||
if (client !== null && this.managementRoomAlias !== undefined) {
|
||||
await teardownManagementRoom(
|
||||
client,
|
||||
|
||||
@@ -135,7 +135,7 @@ export async function makeBotModeToggle(
|
||||
stores: TopLevelStores;
|
||||
eraseAccountData?: boolean;
|
||||
allowSafeMode?: boolean;
|
||||
} = { stores: {} }
|
||||
} = { stores: { dispose() {} } }
|
||||
): Promise<DraupnirBotModeToggle> {
|
||||
await configureMjolnir(config);
|
||||
LogService.setLevel(LogLevel.fromString(config.logLevel, LogLevel.DEBUG));
|
||||
|
||||
@@ -2606,10 +2606,10 @@ matrix-appservice@^2.0.0:
|
||||
"@gnuxie/typescript-result" "^1.0.0"
|
||||
await-lock "^2.2.2"
|
||||
|
||||
"matrix-protection-suite@npm:@gnuxie/matrix-protection-suite@3.6.0":
|
||||
version "3.6.0"
|
||||
resolved "https://registry.yarnpkg.com/@gnuxie/matrix-protection-suite/-/matrix-protection-suite-3.6.0.tgz#efdac7bd00e8ea7c2a273c290d0533536d6d84c7"
|
||||
integrity sha512-9Ner82BaWpwguBDZo4roL05k7SkIOzIde56wVKSjLdP+llyNWCer5K3QhslqnLXXCa7jtRyHpnB44xmmRpUjdg==
|
||||
"matrix-protection-suite@npm:@gnuxie/matrix-protection-suite@3.6.1":
|
||||
version "3.6.1"
|
||||
resolved "https://registry.yarnpkg.com/@gnuxie/matrix-protection-suite/-/matrix-protection-suite-3.6.1.tgz#39739bf127e80fc6b988d8ded34a994727fa12f2"
|
||||
integrity sha512-jDTS4c3E3k0Hkr8Hy39MV1NRTDw3wO7Xik5LW9ilMoj9fBjZ8FTWGrVWQa72SNH8YMIbXh6LLZ6FZJzA8YPfew==
|
||||
dependencies:
|
||||
"@gnuxie/typescript-result" "^1.0.0"
|
||||
await-lock "^2.2.2"
|
||||
|
||||
Reference in New Issue
Block a user