Skip to content

Commit

Permalink
Create a new ping room if the previous room cannot be reached
Browse files Browse the repository at this point in the history
  • Loading branch information
Half-Shot committed May 2, 2023
1 parent 360467e commit 6f579f0
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1707,12 +1707,23 @@ export class Main {

private async pingBridge() {
let internalRoom: string|null;
const intent = this.bridge.getIntent();
try {
internalRoom = await this.datastore.getUserAdminRoom("-internal-");
if (internalRoom) {
try {
await intent.join(internalRoom);
} catch (ex) {
// Unable to join the room, probably broken. Create another.
internalRoom = null;
}
}

if (!internalRoom) {
internalRoom = (await this.bridge.getIntent().createRoom({ options: {}})).room_id;
internalRoom = (await intent.createRoom({ options: {}})).room_id;
await this.datastore.setUserAdminRoom("-internal-", internalRoom);
}

const time = await this.bridge.pingAppserviceRoute(internalRoom);
log.info(`Successfully pinged the bridge. Round trip took ${time}ms`);
}
Expand Down

0 comments on commit 6f579f0

Please sign in to comment.