Browse Source

feat(visitors): Fires events for received visitors message promotion … (#2403)

* feat(visitors): Fires events for received visitors message promotion request/response.

* squash: Updates logs.
release-8443
Дамян Минков 1 year ago
parent
commit
dd81069cb0
No account linked to committer's email address

+ 5
- 0
JitsiConferenceEventManager.js View File

696
         value => {
696
         value => {
697
             conference.eventEmitter.emit(JitsiConferenceEvents.AV_MODERATION_REJECTED, { mediaType: value });
697
             conference.eventEmitter.emit(JitsiConferenceEvents.AV_MODERATION_REJECTED, { mediaType: value });
698
         });
698
         });
699
+
700
+    this._addConferenceXMPPListener(XMPPEvents.VISITORS_MESSAGE,
701
+        value => conference.eventEmitter.emit(JitsiConferenceEvents.VISITORS_MESSAGE, value));
702
+    this._addConferenceXMPPListener(XMPPEvents.VISITORS_REJECTION,
703
+        () => conference.eventEmitter.emit(JitsiConferenceEvents.VISITORS_REJECTION));
699
 };
704
 };
700
 
705
 
701
 /**
706
 /**

+ 5
- 0
JitsiConferenceEvents.spec.ts View File

1
 import * as exported from "./JitsiConferenceEvents";
1
 import * as exported from "./JitsiConferenceEvents";
2
+import {VISITORS_MESSAGE, VISITORS_REJECTION} from "./JitsiConferenceEvents";
2
 
3
 
3
 // this test is brittle on purpose because it's designed to ensure that the TypeScript conversion maintains backward compatibility
4
 // this test is brittle on purpose because it's designed to ensure that the TypeScript conversion maintains backward compatibility
4
 
5
 
68
         USER_ROLE_CHANGED,
69
         USER_ROLE_CHANGED,
69
         USER_STATUS_CHANGED,
70
         USER_STATUS_CHANGED,
70
         VIDEO_UNMUTE_PERMISSIONS_CHANGED,
71
         VIDEO_UNMUTE_PERMISSIONS_CHANGED,
72
+        VISITORS_MESSAGE,
73
+        VISITORS_REJECTION,
71
         BOT_TYPE_CHANGED,
74
         BOT_TYPE_CHANGED,
72
         LOBBY_USER_JOINED,
75
         LOBBY_USER_JOINED,
73
         LOBBY_USER_UPDATED,
76
         LOBBY_USER_UPDATED,
146
         expect( USER_ROLE_CHANGED ).toBe( 'conference.roleChanged' );
149
         expect( USER_ROLE_CHANGED ).toBe( 'conference.roleChanged' );
147
         expect( USER_STATUS_CHANGED ).toBe( 'conference.statusChanged' );
150
         expect( USER_STATUS_CHANGED ).toBe( 'conference.statusChanged' );
148
         expect( VIDEO_UNMUTE_PERMISSIONS_CHANGED ).toBe( 'conference.video_unmute_permissions_changed' );
151
         expect( VIDEO_UNMUTE_PERMISSIONS_CHANGED ).toBe( 'conference.video_unmute_permissions_changed' );
152
+        expect( VISITORS_MESSAGE ).toBe( 'conference.visitors_message' );
153
+        expect( VISITORS_REJECTION ).toBe( 'conference.visitors_rejection' );
149
         expect( BOT_TYPE_CHANGED ).toBe( 'conference.bot_type_changed' );
154
         expect( BOT_TYPE_CHANGED ).toBe( 'conference.bot_type_changed' );
150
         expect( LOBBY_USER_JOINED ).toBe( 'conference.lobby.userJoined' );
155
         expect( LOBBY_USER_JOINED ).toBe( 'conference.lobby.userJoined' );
151
         expect( LOBBY_USER_UPDATED ).toBe( 'conference.lobby.userUpdated' );
156
         expect( LOBBY_USER_UPDATED ).toBe( 'conference.lobby.userUpdated' );

+ 15
- 3
JitsiConferenceEvents.ts View File

235
     PARTCIPANT_FEATURES_CHANGED = 'conference.partcipant_features_changed',
235
     PARTCIPANT_FEATURES_CHANGED = 'conference.partcipant_features_changed',
236
 
236
 
237
     /**
237
     /**
238
-     * Indicates that a the value of a specific property of a specific participant
238
+     * Indicates that a value of a specific property of a specific participant
239
      * has changed.
239
      * has changed.
240
      */
240
      */
241
     PARTICIPANT_PROPERTY_CHANGED = 'conference.participant_property_changed',
241
     PARTICIPANT_PROPERTY_CHANGED = 'conference.participant_property_changed',
280
      *     {string} address,
280
      *     {string} address,
281
      *     {VideoSIPGWConstants} oldState,
281
      *     {VideoSIPGWConstants} oldState,
282
      *     {VideoSIPGWConstants} newState,
282
      *     {VideoSIPGWConstants} newState,
283
-     *     {string} displayName}
283
+     *     {string} displayName
284
      * }.
284
      * }.
285
      */
285
      */
286
     VIDEO_SIP_GW_SESSION_STATE_CHANGED = 'conference.videoSIPGWSessionStateChanged',
286
     VIDEO_SIP_GW_SESSION_STATE_CHANGED = 'conference.videoSIPGWSessionStateChanged',
378
      */
378
      */
379
     VIDEO_UNMUTE_PERMISSIONS_CHANGED = 'conference.video_unmute_permissions_changed',
379
     VIDEO_UNMUTE_PERMISSIONS_CHANGED = 'conference.video_unmute_permissions_changed',
380
 
380
 
381
+    /**
382
+     * Event indicating we have received a message from the visitors component.
383
+     */
384
+    VISITORS_MESSAGE = 'conference.visitors_message',
385
+
386
+    /**
387
+     * Event indicating that our request for promotion was rejected.
388
+     */
389
+    VISITORS_REJECTION = 'conference.visitors_rejection',
390
+
381
     /**
391
     /**
382
      * Event indicates that the bot participant type changed.
392
      * Event indicates that the bot participant type changed.
383
      */
393
      */
464
     E2EE_VERIFICATION_READY = 'conference.e2ee.verification.ready',
474
     E2EE_VERIFICATION_READY = 'conference.e2ee.verification.ready',
465
 
475
 
466
     E2EE_VERIFICATION_COMPLETED = 'conference.e2ee.verification.completed'
476
     E2EE_VERIFICATION_COMPLETED = 'conference.e2ee.verification.completed'
467
-};
477
+}
468
 
478
 
469
 // exported for backward compatibility
479
 // exported for backward compatibility
470
 export const AUDIO_INPUT_STATE_CHANGE = JitsiConferenceEvents.AUDIO_INPUT_STATE_CHANGE;
480
 export const AUDIO_INPUT_STATE_CHANGE = JitsiConferenceEvents.AUDIO_INPUT_STATE_CHANGE;
531
 export const USER_ROLE_CHANGED = JitsiConferenceEvents.USER_ROLE_CHANGED;
541
 export const USER_ROLE_CHANGED = JitsiConferenceEvents.USER_ROLE_CHANGED;
532
 export const USER_STATUS_CHANGED = JitsiConferenceEvents.USER_STATUS_CHANGED;
542
 export const USER_STATUS_CHANGED = JitsiConferenceEvents.USER_STATUS_CHANGED;
533
 export const VIDEO_UNMUTE_PERMISSIONS_CHANGED = JitsiConferenceEvents.VIDEO_UNMUTE_PERMISSIONS_CHANGED;
543
 export const VIDEO_UNMUTE_PERMISSIONS_CHANGED = JitsiConferenceEvents.VIDEO_UNMUTE_PERMISSIONS_CHANGED;
544
+export const VISITORS_MESSAGE = JitsiConferenceEvents.VISITORS_MESSAGE;
545
+export const VISITORS_REJECTION = JitsiConferenceEvents.VISITORS_REJECTION;
534
 export const BOT_TYPE_CHANGED = JitsiConferenceEvents.BOT_TYPE_CHANGED;
546
 export const BOT_TYPE_CHANGED = JitsiConferenceEvents.BOT_TYPE_CHANGED;
535
 export const LOBBY_USER_JOINED = JitsiConferenceEvents.LOBBY_USER_JOINED;
547
 export const LOBBY_USER_JOINED = JitsiConferenceEvents.LOBBY_USER_JOINED;
536
 export const LOBBY_USER_UPDATED = JitsiConferenceEvents.LOBBY_USER_UPDATED;
548
 export const LOBBY_USER_UPDATED = JitsiConferenceEvents.LOBBY_USER_UPDATED;

+ 9
- 6
modules/xmpp/strophe.emuc.js View File

224
         const visitors = $(iq).find('>visitors[xmlns="jitsi:visitors"]');
224
         const visitors = $(iq).find('>visitors[xmlns="jitsi:visitors"]');
225
         const response = $(iq).find('promotion-response');
225
         const response = $(iq).find('promotion-response');
226
 
226
 
227
-        if (visitors.length && response.length
228
-            && String(response.attr('allow')).toLowerCase() === 'true') {
229
-            logger.warn('Redirected back to main room.');
230
-
231
-            this.xmpp.eventEmitter.emit(
232
-                CONNECTION_REDIRECTED, undefined, visitors.attr('focusjid'), response.attr('username'));
227
+        if (visitors.length && response.length) {
228
+            if (String(response.attr('allow')).toLowerCase() === 'true') {
229
+                logger.info('Promotion request accepted. Redirected to main room.');
230
+                this.xmpp.eventEmitter.emit(
231
+                    CONNECTION_REDIRECTED, undefined, visitors.attr('focusjid'), response.attr('username'));
232
+            } else {
233
+                logger.info('Promotion request rejected.');
234
+                this.xmpp.eventEmitter.emit(XMPPEvents.VISITORS_REJECTION);
235
+            }
233
         }
236
         }
234
 
237
 
235
         return true;
238
         return true;

+ 6
- 0
modules/xmpp/xmpp.js View File

525
                 this.roomMetadataComponentAddress = identity.name;
525
                 this.roomMetadataComponentAddress = identity.name;
526
                 this._components.push(this.roomMetadataComponentAddress);
526
                 this._components.push(this.roomMetadataComponentAddress);
527
             }
527
             }
528
+
529
+            if (identity.type === 'visitors') {
530
+                this._components.push(identity.name);
531
+            }
528
         });
532
         });
529
 
533
 
530
         this._maybeSendDeploymentInfoStat(true);
534
         this._maybeSendDeploymentInfoStat(true);
1080
             this.eventEmitter.emit(XMPPEvents.BREAKOUT_ROOMS_EVENT, parsedJson);
1084
             this.eventEmitter.emit(XMPPEvents.BREAKOUT_ROOMS_EVENT, parsedJson);
1081
         } else if (parsedJson[JITSI_MEET_MUC_TYPE] === 'room_metadata') {
1085
         } else if (parsedJson[JITSI_MEET_MUC_TYPE] === 'room_metadata') {
1082
             this.eventEmitter.emit(XMPPEvents.ROOM_METADATA_EVENT, parsedJson);
1086
             this.eventEmitter.emit(XMPPEvents.ROOM_METADATA_EVENT, parsedJson);
1087
+        } else if (parsedJson[JITSI_MEET_MUC_TYPE] === 'visitors') {
1088
+            this.eventEmitter.emit(XMPPEvents.VISITORS_MESSAGE, parsedJson);
1083
         }
1089
         }
1084
 
1090
 
1085
         return true;
1091
         return true;

+ 10
- 0
service/xmpp/XMPPEvents.ts View File

385
      */
385
      */
386
     VIDEO_SIP_GW_SESSION_STATE_CHANGED = 'xmpp.videoSIPGWSessionStateChanged',
386
     VIDEO_SIP_GW_SESSION_STATE_CHANGED = 'xmpp.videoSIPGWSessionStateChanged',
387
 
387
 
388
+    /**
389
+     * Event indicating we have received a message from the visitors component.
390
+     */
391
+    VISITORS_MESSAGE = 'xmpp.visitors_message',
392
+
393
+    /**
394
+     * Event indicating that our request for promotion was rejected.
395
+     */
396
+    VISITORS_REJECTION = 'xmpp.visitors_rejection',
397
+
388
     // Designates an event indicating that the local ICE connection state has
398
     // Designates an event indicating that the local ICE connection state has
389
     // changed.
399
     // changed.
390
     ICE_CONNECTION_STATE_CHANGED = 'xmpp.ice_connection_state_changed',
400
     ICE_CONNECTION_STATE_CHANGED = 'xmpp.ice_connection_state_changed',

Loading…
Cancel
Save