Browse Source

feat: Moves redirected event to connection events.

release-8443
damencho 2 years ago
parent
commit
1151f7cca3

+ 0
- 3
JitsiConferenceErrors.spec.ts View File

@@ -23,7 +23,6 @@ describe( "/JitsiConferenceErrors members", () => {
23 23
         OFFER_ANSWER_FAILED,
24 24
         PASSWORD_NOT_SUPPORTED,
25 25
         PASSWORD_REQUIRED,
26
-        REDIRECTED,
27 26
         RESERVATION_ERROR,
28 27
         VIDEOBRIDGE_NOT_AVAILABLE,
29 28
         JitsiConferenceErrors,
@@ -51,7 +50,6 @@ describe( "/JitsiConferenceErrors members", () => {
51 50
         expect( PASSWORD_NOT_SUPPORTED ).toBe( 'conference.passwordNotSupported' );
52 51
         expect( PASSWORD_REQUIRED ).toBe( 'conference.passwordRequired' );
53 52
         expect( RESERVATION_ERROR ).toBe( 'conference.reservationError' );
54
-        expect( REDIRECTED ).toBe( 'conference.redirected' );
55 53
         expect( VIDEOBRIDGE_NOT_AVAILABLE ).toBe( 'conference.videobridgeNotAvailable' );
56 54
 
57 55
         expect( JitsiConferenceErrors ).toBeDefined();
@@ -76,7 +74,6 @@ describe( "/JitsiConferenceErrors members", () => {
76 74
         expect( JitsiConferenceErrors.PASSWORD_NOT_SUPPORTED ).toBe( 'conference.passwordNotSupported' );
77 75
         expect( JitsiConferenceErrors.PASSWORD_REQUIRED ).toBe( 'conference.passwordRequired' );
78 76
         expect( JitsiConferenceErrors.RESERVATION_ERROR ).toBe( 'conference.reservationError' );
79
-        expect( JitsiConferenceErrors.REDIRECTED ).toBe( 'conference.redirected' );
80 77
         expect( JitsiConferenceErrors.VIDEOBRIDGE_NOT_AVAILABLE ).toBe( 'conference.videobridgeNotAvailable' );
81 78
     } );
82 79
 

+ 1
- 7
JitsiConferenceErrors.ts View File

@@ -105,11 +105,6 @@ export enum JitsiConferenceErrors {
105 105
      */
106 106
     PASSWORD_REQUIRED = 'conference.passwordRequired',
107 107
 
108
-    /**
109
-     * The conference is redirected to a visitor node.
110
-     */
111
-    REDIRECTED = 'conference.redirected',
112
-
113 108
     /**
114 109
      * Indicates that reservation system returned error.
115 110
      */
@@ -119,7 +114,7 @@ export enum JitsiConferenceErrors {
119 114
      * Indicates that there is no available videobridge.
120 115
      */
121 116
     VIDEOBRIDGE_NOT_AVAILABLE = 'conference.videobridgeNotAvailable'
122
-};
117
+}
123 118
 
124 119
 // exported for backward compatibility
125 120
 export const AUTHENTICATION_REQUIRED = JitsiConferenceErrors.AUTHENTICATION_REQUIRED;
@@ -141,6 +136,5 @@ export const INCOMPATIBLE_SERVER_VERSIONS = JitsiConferenceErrors.INCOMPATIBLE_S
141 136
 export const OFFER_ANSWER_FAILED = JitsiConferenceErrors.OFFER_ANSWER_FAILED;
142 137
 export const PASSWORD_NOT_SUPPORTED = JitsiConferenceErrors.PASSWORD_NOT_SUPPORTED;
143 138
 export const PASSWORD_REQUIRED = JitsiConferenceErrors.PASSWORD_REQUIRED;
144
-export const REDIRECTED = JitsiConferenceErrors.REDIRECTED;
145 139
 export const RESERVATION_ERROR = JitsiConferenceErrors.RESERVATION_ERROR;
146 140
 export const VIDEOBRIDGE_NOT_AVAILABLE = JitsiConferenceErrors.VIDEOBRIDGE_NOT_AVAILABLE;

+ 0
- 4
JitsiConferenceEventManager.js View File

@@ -225,10 +225,6 @@ JitsiConferenceEventManager.prototype.setupChatRoomListeners = function() {
225 225
         JitsiConferenceEvents.CONFERENCE_FAILED,
226 226
         JitsiConferenceErrors.AUTHENTICATION_REQUIRED);
227 227
 
228
-    this.chatRoomForwarder.forward(XMPPEvents.REDIRECTED,
229
-        JitsiConferenceEvents.CONFERENCE_FAILED,
230
-        JitsiConferenceErrors.REDIRECTED);
231
-
232 228
     this.chatRoomForwarder.forward(XMPPEvents.BRIDGE_DOWN,
233 229
         JitsiConferenceEvents.CONFERENCE_FAILED,
234 230
         JitsiConferenceErrors.VIDEOBRIDGE_NOT_AVAILABLE);

+ 4
- 1
JitsiConnectionEvents.spec.ts View File

@@ -7,6 +7,7 @@ describe( "/JitsiConnectionEvents members", () => {
7 7
         CONNECTION_DISCONNECTED,
8 8
         CONNECTION_ESTABLISHED,
9 9
         CONNECTION_FAILED,
10
+        CONNECTION_REDIRECTED,
10 11
         WRONG_STATE,
11 12
         DISPLAY_NAME_REQUIRED,
12 13
         JitsiConnectionEvents,
@@ -17,6 +18,7 @@ describe( "/JitsiConnectionEvents members", () => {
17 18
         expect( CONNECTION_DISCONNECTED ).toBe( 'connection.connectionDisconnected' );
18 19
         expect( CONNECTION_ESTABLISHED ).toBe( 'connection.connectionEstablished' );
19 20
         expect( CONNECTION_FAILED ).toBe( 'connection.connectionFailed' );
21
+        expect( CONNECTION_REDIRECTED ).toBe( 'connection.redirected' );
20 22
         expect( WRONG_STATE ).toBe( 'connection.wrongState' );
21 23
         expect( DISPLAY_NAME_REQUIRED ).toBe( 'connection.display_name_required' );
22 24
 
@@ -25,6 +27,7 @@ describe( "/JitsiConnectionEvents members", () => {
25 27
         expect( JitsiConnectionEvents.CONNECTION_DISCONNECTED ).toBe( 'connection.connectionDisconnected' );
26 28
         expect( JitsiConnectionEvents.CONNECTION_ESTABLISHED ).toBe( 'connection.connectionEstablished' );
27 29
         expect( JitsiConnectionEvents.CONNECTION_FAILED ).toBe( 'connection.connectionFailed' );
30
+        expect( JitsiConnectionEvents.CONNECTION_REDIRECTED ).toBe( 'connection.redirected' );
28 31
         expect( JitsiConnectionEvents.WRONG_STATE ).toBe( 'connection.wrongState' );
29 32
         expect( JitsiConnectionEvents.DISPLAY_NAME_REQUIRED ).toBe( 'connection.display_name_required' );
30 33
     } );
@@ -33,4 +36,4 @@ describe( "/JitsiConnectionEvents members", () => {
33 36
         const keys = Object.keys( others );
34 37
         expect( keys ).withContext( `Extra members: ${ keys.join( ", " ) }` ).toEqual( [] );
35 38
     } );
36
-} );
39
+} );

+ 7
- 1
JitsiConnectionEvents.ts View File

@@ -34,6 +34,11 @@ export enum JitsiConnectionEvents {
34 34
      */
35 35
     CONNECTION_FAILED = 'connection.connectionFailed',
36 36
 
37
+    /**
38
+     * The connection is redirected to a visitor node.
39
+     */
40
+    CONNECTION_REDIRECTED = 'connection.redirected',
41
+
37 42
     /**
38 43
      * Indicates that the performed action cannot be executed because the
39 44
      * connection is not in the correct state(connected, disconnected, etc.)
@@ -46,11 +51,12 @@ export enum JitsiConnectionEvents {
46 51
      * There are cases like lobby room where display name is required.
47 52
      */
48 53
     DISPLAY_NAME_REQUIRED = 'connection.display_name_required'
49
-};
54
+}
50 55
 
51 56
 // exported for backward compatibility
52 57
 export const CONNECTION_DISCONNECTED = JitsiConnectionEvents.CONNECTION_DISCONNECTED;
53 58
 export const CONNECTION_ESTABLISHED = JitsiConnectionEvents.CONNECTION_ESTABLISHED;
54 59
 export const CONNECTION_FAILED = JitsiConnectionEvents.CONNECTION_FAILED;
60
+export const CONNECTION_REDIRECTED = JitsiConnectionEvents.CONNECTION_REDIRECTED;
55 61
 export const WRONG_STATE = JitsiConnectionEvents.WRONG_STATE;
56 62
 export const DISPLAY_NAME_REQUIRED = JitsiConnectionEvents.DISPLAY_NAME_REQUIRED;

+ 0
- 19
modules/xmpp/ChatRoom.js View File

@@ -172,7 +172,6 @@ export default class ChatRoom extends Listenable {
172 172
 
173 173
         this.eventsForwarder = new EventEmitterForwarder(this.xmpp.moderator, this.eventEmitter);
174 174
         this.eventsForwarder.forward(AuthenticationEvents.IDENTITY_UPDATED, AuthenticationEvents.IDENTITY_UPDATED);
175
-        this.eventsForwarder.forward(XMPPEvents.REDIRECTED, XMPPEvents.REDIRECTED);
176 175
         this.eventsForwarder.forward(XMPPEvents.AUTHENTICATION_REQUIRED, XMPPEvents.AUTHENTICATION_REQUIRED);
177 176
         this.eventsForwarder.forward(XMPPEvents.FOCUS_DISCONNECTED, XMPPEvents.FOCUS_DISCONNECTED);
178 177
         this.eventsForwarder.forward(XMPPEvents.RESERVATION_ERROR, XMPPEvents.RESERVATION_ERROR);
@@ -1593,23 +1592,6 @@ export default class ChatRoom extends Listenable {
1593 1592
         return this.role === 'moderator';
1594 1593
     }
1595 1594
 
1596
-    /**
1597
-     * Redirected back.
1598
-     * @param iq The received iq.
1599
-     */
1600
-    onVisitorIQ(iq) {
1601
-        const visitors = $(iq).find('>visitors[xmlns="jitsi:visitors"]');
1602
-        const response = $(iq).find('promotion-response');
1603
-
1604
-        if (visitors.length && response.length
1605
-            && String(response.attr('allow')).toLowerCase() === 'true') {
1606
-            logger.warn('Redirected back to main room.');
1607
-
1608
-            this.eventEmitter.emit(
1609
-                XMPPEvents.REDIRECTED, undefined, visitors.attr('focusjid'), response.attr('username'));
1610
-        }
1611
-    }
1612
-
1613 1595
     /**
1614 1596
      * Obtains the info about given media advertised (in legacy format) in the MUC presence of the participant
1615 1597
      * identified by the given endpoint JID. This is for mantining interop with endpoints that do not support
@@ -1833,7 +1815,6 @@ export default class ChatRoom extends Listenable {
1833 1815
 
1834 1816
         this.eventsForwarder.removeListeners(
1835 1817
             AuthenticationEvents.IDENTITY_UPDATED,
1836
-            XMPPEvents.REDIRECTED,
1837 1818
             XMPPEvents.AUTHENTICATION_REQUIRED,
1838 1819
             XMPPEvents.FOCUS_DISCONNECTED,
1839 1820
             XMPPEvents.RESERVATION_ERROR);

+ 3
- 1
modules/xmpp/moderator.js View File

@@ -3,6 +3,7 @@ import { getLogger } from '@jitsi/logger';
3 3
 import $ from 'jquery';
4 4
 import { $iq, Strophe } from 'strophe.js';
5 5
 
6
+import { CONNECTION_REDIRECTED } from '../../JitsiConnectionEvents';
6 7
 import FeatureFlags from '../flags/FeatureFlags';
7 8
 import Settings from '../settings/Settings';
8 9
 import Listenable from '../util/Listenable';
@@ -61,6 +62,7 @@ export default class Moderator extends Listenable {
61 62
         // availability.
62 63
         this.sipGatewayEnabled = false;
63 64
 
65
+        this.xmpp = xmpp;
64 66
         this.connection = xmpp.connection;
65 67
 
66 68
         // The JID to which conference-iq requests are sent over XMPP.
@@ -393,7 +395,7 @@ export default class Moderator extends Listenable {
393 395
             if (conferenceRequest.vnode && !this.options.iAmRecorder && !this.options.iAmSipGateway) {
394 396
                 logger.warn(`Redirected to: ${conferenceRequest.vnode} with focusJid ${conferenceRequest.focusJid} }`);
395 397
 
396
-                this.eventEmitter.emit(XMPPEvents.REDIRECTED, conferenceRequest.vnode, conferenceRequest.focusJid);
398
+                this.xmpp.eventEmitter.emit(CONNECTION_REDIRECTED, conferenceRequest.vnode, conferenceRequest.focusJid);
397 399
 
398 400
                 return;
399 401
             }

+ 15
- 1
modules/xmpp/strophe.emuc.js View File

@@ -2,6 +2,7 @@ import { getLogger } from '@jitsi/logger';
2 2
 import $ from 'jquery';
3 3
 import { Strophe } from 'strophe.js';
4 4
 
5
+import { CONNECTION_REDIRECTED } from '../../JitsiConnectionEvents';
5 6
 import { XMPPEvents } from '../../service/xmpp/XMPPEvents';
6 7
 
7 8
 import ChatRoom from './ChatRoom';
@@ -216,7 +217,20 @@ export default class MucConnectionPlugin extends ConnectionPluginListenable {
216 217
         const from = iq.getAttribute('from');
217 218
         const room = this.rooms[Strophe.getBareJidFromJid(from)];
218 219
 
219
-        room?.onVisitorIQ(iq);
220
+        if (!room) {
221
+            return true;
222
+        }
223
+
224
+        const visitors = $(iq).find('>visitors[xmlns="jitsi:visitors"]');
225
+        const response = $(iq).find('promotion-response');
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'));
233
+        }
220 234
 
221 235
         return true;
222 236
     }

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

@@ -209,11 +209,6 @@ export enum XMPPEvents {
209 209
      */
210 210
     RECORDER_STATE_CHANGED = 'xmpp.recorderStateChanged',
211 211
 
212
-    /**
213
-     * The conference was redirected to a visitor node.
214
-     */
215
-    REDIRECTED = 'xmpp.redirected',
216
-
217 212
     // Designates an event indicating that we received statistics from a
218 213
     // participant in the MUC.
219 214
     REMOTE_STATS = 'xmpp.remote_stats',

Loading…
Cancel
Save