Skip to content

Commit ec98b02

Browse files
committedMay 3, 2024
feat: Detects different not-allowed errors.
1 parent 58a9144 commit ec98b02

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed
 

‎JitsiConferenceErrors.spec.ts

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as exported from "./JitsiConferenceErrors";
44

55
describe( "/JitsiConferenceErrors members", () => {
66
const {
7+
AUTH_ERROR_TYPES,
78
AUTHENTICATION_REQUIRED,
89
CHAT_ERROR,
910
SETTINGS_ERROR,
@@ -30,6 +31,11 @@ describe( "/JitsiConferenceErrors members", () => {
3031
} = exported;
3132

3233
it( "known members", () => {
34+
expect( AUTH_ERROR_TYPES.GENERAL ).toBe( 'general' );
35+
expect( AUTH_ERROR_TYPES.NO_MAIN_PARTICIPANTS ).toBe( 'no-main-participants' );
36+
expect( AUTH_ERROR_TYPES.NO_VISITORS_LOBBY ).toBe( 'no-visitors-lobby' );
37+
expect( AUTH_ERROR_TYPES.PROMOTION_NOT_ALLOWED ).toBe( 'promotion-not-allowed' );
38+
expect( AUTH_ERROR_TYPES.ROOM_CREATION_RESTRICTION ).toBe( 'room-creation-restriction' );
3339
expect( AUTHENTICATION_REQUIRED ).toBe( 'conference.authenticationRequired' );
3440
expect( CHAT_ERROR ).toBe( 'conference.chatError' );
3541
expect( SETTINGS_ERROR ).toBe( 'conference.settingsError' );

‎JitsiConferenceErrors.ts

+11
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,17 @@ export enum JitsiConferenceErrors {
116116
VIDEOBRIDGE_NOT_AVAILABLE = 'conference.videobridgeNotAvailable'
117117
}
118118

119+
/**
120+
* Types that are passed for NOT_ALLOWED_ERROR.
121+
*/
122+
export enum AUTH_ERROR_TYPES {
123+
GENERAL = 'general',
124+
NO_MAIN_PARTICIPANTS = 'no-main-participants',
125+
NO_VISITORS_LOBBY = 'no-visitors-lobby',
126+
PROMOTION_NOT_ALLOWED = 'promotion-not-allowed',
127+
ROOM_CREATION_RESTRICTION = 'room-creation-restriction'
128+
}
129+
119130
// exported for backward compatibility
120131
export const AUTHENTICATION_REQUIRED = JitsiConferenceErrors.AUTHENTICATION_REQUIRED;
121132
export const CHAT_ERROR = JitsiConferenceErrors.CHAT_ERROR;

‎JitsiMeetJS.ts

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { TrackStreamingStatus } from './modules/connectivity/TrackStreamingStatu
1919
import getActiveAudioDevice from './modules/detection/ActiveDeviceDetector';
2020
import * as DetectionEvents from './modules/detection/DetectionEvents';
2121
import TrackVADEmitter from './modules/detection/TrackVADEmitter';
22-
import FeatureFlags from './modules/flags/FeatureFlags';
2322
import ProxyConnectionService
2423
from './modules/proxyconnection/ProxyConnectionService';
2524
import recordingConstants from './modules/recording/recordingConstants';

‎modules/xmpp/ChatRoom.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import $ from 'jquery';
44
import isEqual from 'lodash.isequal';
55
import { $iq, $msg, $pres, Strophe } from 'strophe.js';
66

7+
import { AUTH_ERROR_TYPES } from '../../JitsiConferenceErrors';
78
import * as JitsiTranscriptionStatus from '../../JitsiTranscriptionStatus';
89
import { MediaType } from '../../service/RTC/MediaType';
910
import { VideoType } from '../../service/RTC/VideoType';
@@ -1254,11 +1255,14 @@ export default class ChatRoom extends Listenable {
12541255

12551256
const txtNode = $(pres).find('>error[type="cancel"]>text[xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"]');
12561257
const txt = txtNode.length && txtNode.text();
1258+
let type = AUTH_ERROR_TYPES.GENERAL;
12571259

12581260
// a race where we have sent a conference request to jicofo and jicofo was about to leave or just left
12591261
// because of no participants in the room, and we tried to create the room, without having
12601262
// permissions for that (only jicofo creates rooms)
12611263
if (txt === 'Room creation is restricted') {
1264+
type = AUTH_ERROR_TYPES.ROOM_CREATION_RESTRICTION;
1265+
12621266
if (!this._roomCreationRetries) {
12631267
this._roomCreationRetries = 0;
12641268
}
@@ -1275,9 +1279,18 @@ export default class ChatRoom extends Listenable {
12751279

12761280
return;
12771281
}
1282+
} else if ($(pres).find(
1283+
'>error[type="cancel"]>no-main-participants[xmlns="jitsi:visitors"]').length > 0) {
1284+
type = AUTH_ERROR_TYPES.NO_MAIN_PARTICIPANTS;
1285+
} else if ($(pres).find(
1286+
'>error[type="cancel"]>promotion-not-allowed[xmlns="jitsi:visitors"]').length > 0) {
1287+
type = AUTH_ERROR_TYPES.PROMOTION_NOT_ALLOWED;
1288+
} else if ($(pres).find(
1289+
'>error[type="cancel"]>no-visitors-lobby[xmlns="jitsi:visitors"]').length > 0) {
1290+
type = AUTH_ERROR_TYPES.NO_VISITORS_LOBBY;
12781291
}
12791292

1280-
this.eventEmitter.emit(XMPPEvents.ROOM_CONNECT_NOT_ALLOWED_ERROR, txt);
1293+
this.eventEmitter.emit(XMPPEvents.ROOM_CONNECT_NOT_ALLOWED_ERROR, type, txt);
12811294
}
12821295
} else if ($(pres).find('>error>service-unavailable').length) {
12831296
logger.warn('Maximum users limit for the room has been reached',

0 commit comments

Comments
 (0)