diff --git a/JitsiConferenceErrors.spec.ts b/JitsiConferenceErrors.spec.ts index 5eca85a7ed..5825759bd3 100644 --- a/JitsiConferenceErrors.spec.ts +++ b/JitsiConferenceErrors.spec.ts @@ -4,6 +4,7 @@ import * as exported from "./JitsiConferenceErrors"; describe( "/JitsiConferenceErrors members", () => { const { + AUTH_ERROR_TYPES, AUTHENTICATION_REQUIRED, CHAT_ERROR, SETTINGS_ERROR, @@ -30,6 +31,11 @@ describe( "/JitsiConferenceErrors members", () => { } = exported; it( "known members", () => { + expect( AUTH_ERROR_TYPES.GENERAL ).toBe( 'general' ); + expect( AUTH_ERROR_TYPES.NO_MAIN_PARTICIPANTS ).toBe( 'no-main-participants' ); + expect( AUTH_ERROR_TYPES.NO_VISITORS_LOBBY ).toBe( 'no-visitors-lobby' ); + expect( AUTH_ERROR_TYPES.PROMOTION_NOT_ALLOWED ).toBe( 'promotion-not-allowed' ); + expect( AUTH_ERROR_TYPES.ROOM_CREATION_RESTRICTION ).toBe( 'room-creation-restriction' ); expect( AUTHENTICATION_REQUIRED ).toBe( 'conference.authenticationRequired' ); expect( CHAT_ERROR ).toBe( 'conference.chatError' ); expect( SETTINGS_ERROR ).toBe( 'conference.settingsError' ); diff --git a/JitsiConferenceErrors.ts b/JitsiConferenceErrors.ts index e133b0f2d0..62f8babfb3 100644 --- a/JitsiConferenceErrors.ts +++ b/JitsiConferenceErrors.ts @@ -116,6 +116,17 @@ export enum JitsiConferenceErrors { VIDEOBRIDGE_NOT_AVAILABLE = 'conference.videobridgeNotAvailable' } +/** + * Types that are passed for NOT_ALLOWED_ERROR. + */ +export enum AUTH_ERROR_TYPES { + GENERAL = 'general', + NO_MAIN_PARTICIPANTS = 'no-main-participants', + NO_VISITORS_LOBBY = 'no-visitors-lobby', + PROMOTION_NOT_ALLOWED = 'promotion-not-allowed', + ROOM_CREATION_RESTRICTION = 'room-creation-restriction' +} + // exported for backward compatibility export const AUTHENTICATION_REQUIRED = JitsiConferenceErrors.AUTHENTICATION_REQUIRED; export const CHAT_ERROR = JitsiConferenceErrors.CHAT_ERROR; diff --git a/JitsiMeetJS.ts b/JitsiMeetJS.ts index 9fa087f420..b7fff14a6c 100644 --- a/JitsiMeetJS.ts +++ b/JitsiMeetJS.ts @@ -19,7 +19,6 @@ import { TrackStreamingStatus } from './modules/connectivity/TrackStreamingStatu import getActiveAudioDevice from './modules/detection/ActiveDeviceDetector'; import * as DetectionEvents from './modules/detection/DetectionEvents'; import TrackVADEmitter from './modules/detection/TrackVADEmitter'; -import FeatureFlags from './modules/flags/FeatureFlags'; import ProxyConnectionService from './modules/proxyconnection/ProxyConnectionService'; import recordingConstants from './modules/recording/recordingConstants'; diff --git a/modules/xmpp/ChatRoom.js b/modules/xmpp/ChatRoom.js index 7172b01f51..fabadbbf54 100644 --- a/modules/xmpp/ChatRoom.js +++ b/modules/xmpp/ChatRoom.js @@ -4,6 +4,7 @@ import $ from 'jquery'; import isEqual from 'lodash.isequal'; import { $iq, $msg, $pres, Strophe } from 'strophe.js'; +import { AUTH_ERROR_TYPES } from '../../JitsiConferenceErrors'; import * as JitsiTranscriptionStatus from '../../JitsiTranscriptionStatus'; import { MediaType } from '../../service/RTC/MediaType'; import { VideoType } from '../../service/RTC/VideoType'; @@ -1254,11 +1255,14 @@ export default class ChatRoom extends Listenable { const txtNode = $(pres).find('>error[type="cancel"]>text[xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"]'); const txt = txtNode.length && txtNode.text(); + let type = AUTH_ERROR_TYPES.GENERAL; // 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 === 'Room creation is restricted') { + type = AUTH_ERROR_TYPES.ROOM_CREATION_RESTRICTION; + if (!this._roomCreationRetries) { this._roomCreationRetries = 0; } @@ -1275,9 +1279,18 @@ export default class ChatRoom extends Listenable { return; } + } else if ($(pres).find( + '>error[type="cancel"]>no-main-participants[xmlns="jitsi:visitors"]').length > 0) { + type = AUTH_ERROR_TYPES.NO_MAIN_PARTICIPANTS; + } else if ($(pres).find( + '>error[type="cancel"]>promotion-not-allowed[xmlns="jitsi:visitors"]').length > 0) { + type = AUTH_ERROR_TYPES.PROMOTION_NOT_ALLOWED; + } else if ($(pres).find( + '>error[type="cancel"]>no-visitors-lobby[xmlns="jitsi:visitors"]').length > 0) { + type = AUTH_ERROR_TYPES.NO_VISITORS_LOBBY; } - this.eventEmitter.emit(XMPPEvents.ROOM_CONNECT_NOT_ALLOWED_ERROR, txt); + this.eventEmitter.emit(XMPPEvents.ROOM_CONNECT_NOT_ALLOWED_ERROR, type, txt); } } else if ($(pres).find('>error>service-unavailable').length) { logger.warn('Maximum users limit for the room has been reached',