Skip to content

Commit

Permalink
stop managed mjolnirs
Browse files Browse the repository at this point in the history
  • Loading branch information
H-Shay committed Oct 21, 2024
1 parent fac9f2d commit 294b25c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/appservice/AppService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ export class MjolnirAppService {
await this.dataStore.close();
await this.api.close();
this.openMetrics.stop();
this.mjolnirManager.closeAll();
}

/**
Expand Down
11 changes: 11 additions & 0 deletions src/appservice/MjolnirManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,13 @@ export class MjolnirManager {
}
}

public closeAll() {
for (const mjolnir of this.perMjolnirId.values()) {
mjolnir.stop()
}
}


/**
* Utility that creates a matrix client for a virtual user on our homeserver with the specified loclapart.
* @param localPart The localpart of the virtual user we need a client for.
Expand Down Expand Up @@ -246,6 +253,10 @@ export class ManagedMjolnir {
await this.mjolnir.start();
}

public stop() {
this.mjolnir.stop();
}

public async getUserId(): Promise<string> {
return await this.mjolnir.client.getUserId();
}
Expand Down
1 change: 1 addition & 0 deletions test/appservice/integration/provisionTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ describe("Test that the app service can provision a mjolnir on invite of the app
await getFirstReply(moderator, managementRoomId, () => {
return moderator.sendMessage(managementRoomId, { body: `!mjolnir status`, msgtype: "m.text" });
});
await this.appservice
});
});

0 comments on commit 294b25c

Please sign in to comment.