Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

If public room creation fails, retry without publishing it #6872

Merged
merged 6 commits into from
Oct 12, 2021
8 changes: 8 additions & 0 deletions src/createRoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,14 @@ export default async function createRoom(opts: IOpts): Promise<string | null> {
let roomId;
return client.createRoom(createOpts).finally(function() {
if (modal) modal.close();
t3chguy marked this conversation as resolved.
Show resolved Hide resolved
}).catch(function(err) {
if (err.httpStatus === 403 && err.errcode == "M_UNKNOWN") {
t3chguy marked this conversation as resolved.
Show resolved Hide resolved
console.warn("Failed to publish room, try again without publishing it");
createOpts.visibility = Visibility.Private;
return client.createRoom(createOpts);
} else {
return Promise.reject(err);
}
}).then(function(res) {
roomId = res.room_id;
if (opts.dmUserId) {
Expand Down