diff --git a/src/matrix/Session.js b/src/matrix/Session.js index 38771c87..a2c77752 100644 --- a/src/matrix/Session.js +++ b/src/matrix/Session.js @@ -717,6 +717,13 @@ export class Session { } }); } + + joinRoom(roomIdOrAlias, log = null) { + return this._platform.logger.wrapOrRun(log, "joinRoom", async log => { + const body = await this._hsApi.joinIdOrAlias(roomIdOrAlias).response(); + return body.room_id; + }); + } } export function tests() { diff --git a/src/matrix/net/HomeServerApi.js b/src/matrix/net/HomeServerApi.js index a3fe1bc9..f834b94b 100644 --- a/src/matrix/net/HomeServerApi.js +++ b/src/matrix/net/HomeServerApi.js @@ -190,6 +190,10 @@ export class HomeServerApi { return this._post(`/rooms/${encodeURIComponent(roomId)}/join`, null, null, options); } + joinIdOrAlias(roomIdOrAlias, options = null) { + return this._post(`/join/${encodeURIComponent(roomIdOrAlias)}`, null, null, options); + } + leave(roomId, options = null) { return this._post(`/rooms/${encodeURIComponent(roomId)}/leave`, null, null, options); }