allow to join room by id or alias

This commit is contained in:
Bruno Windels 2021-05-18 11:05:31 +02:00
parent a4d3b5f013
commit 9679058081
2 changed files with 11 additions and 0 deletions

View file

@ -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() {

View file

@ -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);
}