mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-16 21:24:59 +08:00
Merge pull request #6872 from AndrewFerr/develop
If public room creation fails, retry without publishing it
This commit is contained in:
commit
34b61ad71c
@ -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');
|
if (opts.spinner) modal = Modal.createDialog(Spinner, null, 'mx_Dialog_spinner');
|
||||||
|
|
||||||
let roomId;
|
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();
|
if (modal) modal.close();
|
||||||
}).then(function(res) {
|
}).then(function(res) {
|
||||||
roomId = res.room_id;
|
roomId = res.room_id;
|
||||||
|
Loading…
Reference in New Issue
Block a user