Skip to content

Commit

Permalink
feat: Retries joining the room on room creation error.
Browse files Browse the repository at this point in the history
  • Loading branch information
damencho committed Nov 3, 2023
1 parent 30be4f6 commit f8a18cf
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions modules/xmpp/ChatRoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,26 @@ export default class ChatRoom extends Listenable {

} else {
logger.warn('onPresError ', pres);

const txt = $(pres).find('>error[type="cancel"]>text[xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"]');

// a race where we have sent a conference request to jicofo and jicofo was about to leave or just left
// because of no participants in the room, and we tried to create the room, without having
// permissions for that (only jicofo creates rooms)
if (txt.length && txt.text() === 'Room creation is restricted') {
if (!this._roomCreationRetries) {
this._roomCreationRetries = 0;
}
this._roomCreationRetries++;

if (this._roomCreationRetries <= 3) {
// let's retry inviting jicofo and joining the room
this.join(this.password, this.replaceParticipant);

return;
}
}

this.eventEmitter.emit(
XMPPEvents.ROOM_CONNECT_NOT_ALLOWED_ERROR);
}
Expand Down

0 comments on commit f8a18cf

Please sign in to comment.