Explorar el Código

feat: Listens for visitor IQs. (#2241)

master
Дамян Минков hace 2 años
padre
commit
6e6c7d8915
No account linked to committer's email address
Se han modificado 2 ficheros con 33 adiciones y 0 borrados
  1. 17
    0
      modules/xmpp/ChatRoom.js
  2. 16
    0
      modules/xmpp/strophe.emuc.js

+ 17
- 0
modules/xmpp/ChatRoom.js Ver fichero

@@ -1571,6 +1571,23 @@ export default class ChatRoom extends Listenable {
1571 1571
         return this.role === 'moderator';
1572 1572
     }
1573 1573
 
1574
+    /**
1575
+     * Redirected back.
1576
+     * @param iq The received iq.
1577
+     */
1578
+    onVisitorIQ(iq) {
1579
+        const visitors = $(iq).find('>visitors[xmlns="jitsi:visitors"]');
1580
+        const response = $(iq).find('response-promotion');
1581
+
1582
+        if (visitors.length && response.length
1583
+            && String(response.attr('allow')).toLowerCase() === 'true') {
1584
+            logger.warn('Redirected back to main room.');
1585
+
1586
+            this.eventEmitter.emit(
1587
+                XMPPEvents.REDIRECTED, undefined, visitors.attr('focusjid'), response.attr('username'));
1588
+        }
1589
+    }
1590
+
1574 1591
     /**
1575 1592
      * Obtains the info about given media advertised (in legacy format) in the MUC presence of the participant
1576 1593
      * identified by the given endpoint JID. This is for mantining interop with endpoints that do not support

+ 16
- 0
modules/xmpp/strophe.emuc.js Ver fichero

@@ -43,6 +43,8 @@ export default class MucConnectionPlugin extends ConnectionPluginListenable {
43 43
             'http://jitsi.org/jitmeet/audio', 'iq', 'set', null, null);
44 44
         this.connection.addHandler(this.onMuteVideo.bind(this),
45 45
             'http://jitsi.org/jitmeet/video', 'iq', 'set', null, null);
46
+        this.connection.addHandler(this.onVisitors.bind(this),
47
+            'jitsi:visitors', 'iq', 'set', null, null);
46 48
     }
47 49
 
48 50
     /**
@@ -204,4 +206,18 @@ export default class MucConnectionPlugin extends ConnectionPluginListenable {
204 206
 
205 207
         return true;
206 208
     }
209
+
210
+    /**
211
+     * A visitor IQ is received, pass it to the room.
212
+     * @param iq The received iq.
213
+     * @returns {boolean}
214
+     */
215
+    onVisitors(iq) {
216
+        const from = iq.getAttribute('from');
217
+        const room = this.rooms[Strophe.getBareJidFromJid(from)];
218
+
219
+        room?.onVisitorIQ(iq);
220
+
221
+        return true;
222
+    }
207 223
 }

Loading…
Cancelar
Guardar