浏览代码

feat: Listens for visitor IQs. (#2241)

master
Дамян Минков 2 年前
父节点
当前提交
6e6c7d8915
没有帐户链接到提交者的电子邮件
共有 2 个文件被更改,包括 33 次插入0 次删除
  1. 17
    0
      modules/xmpp/ChatRoom.js
  2. 16
    0
      modules/xmpp/strophe.emuc.js

+ 17
- 0
modules/xmpp/ChatRoom.js 查看文件

1571
         return this.role === 'moderator';
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
      * Obtains the info about given media advertised (in legacy format) in the MUC presence of the participant
1592
      * Obtains the info about given media advertised (in legacy format) in the MUC presence of the participant
1576
      * identified by the given endpoint JID. This is for mantining interop with endpoints that do not support
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 查看文件

43
             'http://jitsi.org/jitmeet/audio', 'iq', 'set', null, null);
43
             'http://jitsi.org/jitmeet/audio', 'iq', 'set', null, null);
44
         this.connection.addHandler(this.onMuteVideo.bind(this),
44
         this.connection.addHandler(this.onMuteVideo.bind(this),
45
             'http://jitsi.org/jitmeet/video', 'iq', 'set', null, null);
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
 
206
 
205
         return true;
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
 }

正在加载...
取消
保存