Merge pull request #6872 from AndrewFerr/develop

If public room creation fails, retry without publishing it
pull/21833/head
Michael Telatynski 2021-10-12 10:32:43 +01:00 committed by GitHub
commit 34b61ad71c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 1 deletions

View File

@ -219,7 +219,19 @@ export default async function createRoom(opts: IOpts): Promise<string | null> {
if (opts.spinner) modal = Modal.createDialog(Spinner, null, 'mx_Dialog_spinner');
let roomId;
return client.createRoom(createOpts).finally(function() {
return client.createRoom(createOpts).catch(function(err) {
// NB This checks for the Synapse-specific error condition of a room creation
// having been denied because the requesting user wanted to publish the room,
// but the server denies them that permission (via room_list_publication_rules).
// The check below responds by retrying without publishing the room.
if (err.httpStatus === 403 && err.errcode === "M_UNKNOWN" && err.data.error === "Not allowed to publish room") {
console.warn("Failed to publish room, try again without publishing it");
createOpts.visibility = Visibility.Private;
return client.createRoom(createOpts);
} else {
return Promise.reject(err);
}
}).finally(function() {
if (modal) modal.close();
}).then(function(res) {
roomId = res.room_id;