Skip to content

Commit

Permalink
Fix the bot-sdk crypto by initializing the bot-sdk earlier (#512)
Browse files Browse the repository at this point in the history
* Fix the bot-sdk crypto by initializing the bot-sdk earlier

Signed-off-by: MTRNord <mtrnord1@gmail.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix formatting

Signed-off-by: MTRNord <mtrnord1@gmail.com>

* Instead of moving the sync start we move the one message causing issues. This makes sure we are actually ready for incoming messages

Signed-off-by: MTRNord <mtrnord1@gmail.com>

* Add a comment on why the startupComplete method is public

---------

Signed-off-by: MTRNord <mtrnord1@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
MTRNord and pre-commit-ci[bot] authored Aug 17, 2024
1 parent cc9d4cb commit 7146216
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,6 @@ mjolnir.egg-info/
.yarn
# Only contains possibly broken path, replaced by .yarnrc.yml in modern Yarn
.yarnrc

# VS Code workspace settings
/.vscode
8 changes: 6 additions & 2 deletions src/Draupnir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,15 @@ export class Draupnir implements Client {
if (isError(managementRoomProtectResult)) {
return managementRoomProtectResult;
}
void Task(draupnir.startupComplete());
return Ok(draupnir);
}

private async startupComplete(): Promise<void> {
/**
* Note: This is only public due to having to first start the syncloop before sending events
* when we use encryption.
* This means this is only used in the index.ts.
*/
public async startupComplete(): Promise<void> {
const statusInfo = await draupnirStatusInfo(this);
try {
await this.managementRoomOutput.logMessage(
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
} from "./DraupnirBotMode";
import { Draupnir } from "./Draupnir";
import { SafeMatrixEmitterWrapper } from "matrix-protection-suite-for-matrix-bot-sdk";
import { DefaultEventDecoder } from "matrix-protection-suite";
import { DefaultEventDecoder, Task } from "matrix-protection-suite";
import { WebAPIs } from "./webapis/WebAPIs";
import { SqliteRoomStateBackingStore } from "./backingstore/better-sqlite3/SqliteRoomStateBackingStore";

Expand Down Expand Up @@ -120,6 +120,7 @@ void (async function () {
try {
await bot.start();
await config.RUNTIME.client.start();
void Task(bot.startupComplete());
await apis.start();
healthz.isHealthy = true;
} catch (err) {
Expand Down

0 comments on commit 7146216

Please sign in to comment.