浏览代码

feat(lobby): Adds an option to approve multiple participants.

release-8443
damencho 1年前
父节点
当前提交
016528b96c
共有 2 个文件被更改,包括 29 次插入14 次删除
  1. 3
    3
      JitsiConference.js
  2. 26
    11
      modules/xmpp/Lobby.js

+ 3
- 3
JitsiConference.js 查看文件

@@ -4012,11 +4012,11 @@ JitsiConference.prototype.lobbyDenyAccess = function(id) {
4012 4012
 /**
4013 4013
  * Approves the request to join the conference to a participant waiting in the lobby.
4014 4014
  *
4015
- * @param {string} id The participant id.
4015
+ * @param {string|Array<string>} param The participant id or an array of ids.
4016 4016
  */
4017
-JitsiConference.prototype.lobbyApproveAccess = function(id) {
4017
+JitsiConference.prototype.lobbyApproveAccess = function(param) {
4018 4018
     if (this.room) {
4019
-        this.room.getLobby().approveAccess(id);
4019
+        this.room.getLobby().approveAccess(param);
4020 4020
     }
4021 4021
 };
4022 4022
 

+ 26
- 11
modules/xmpp/Lobby.js 查看文件

@@ -410,9 +410,9 @@ export default class Lobby {
410 410
 
411 411
     /**
412 412
      * Should be possible only for moderators.
413
-     * @param id
413
+     * @param param or an array of ids.
414 414
      */
415
-    approveAccess(id) {
415
+    approveAccess(param) {
416 416
         if (!this.isSupported() || !this.mainRoom.isModerator()) {
417 417
             return;
418 418
         }
@@ -425,23 +425,38 @@ export default class Lobby {
425 425
             mainRoomJid = this.mainRoom.getBreakoutRooms().getMainRoomJid();
426 426
         }
427 427
 
428
-        const memberRoomJid = Object.keys(this.lobbyRoom.members)
429
-            .find(j => Strophe.getResourceFromJid(j) === id);
428
+        const membersToApprove = [];
429
+        let ids = param;
430
+
431
+        if (!Array.isArray(param)) {
432
+            ids = [ param ];
433
+        }
434
+
435
+        ids.forEach(id => {
436
+            const memberRoomJid = Object.keys(this.lobbyRoom.members)
437
+                .find(j => Strophe.getResourceFromJid(j) === id);
430 438
 
431
-        if (memberRoomJid) {
432
-            const jid = this.lobbyRoom.members[memberRoomJid].jid;
439
+            if (memberRoomJid) {
440
+                membersToApprove.push(this.lobbyRoom.members[memberRoomJid].jid);
441
+            } else {
442
+                logger.error(`Not found member for ${memberRoomJid} in lobby room.`);
443
+            }
444
+        });
445
+
446
+        if (membersToApprove.length > 0) {
433 447
             const msgToSend
434 448
                 = $msg({ to: mainRoomJid })
435
-                    .c('x', { xmlns: 'http://jabber.org/protocol/muc#user' })
436
-                    .c('invite', { to: jid });
449
+                    .c('x', { xmlns: 'http://jabber.org/protocol/muc#user' });
450
+
451
+            membersToApprove.forEach(jid => {
452
+                msgToSend.c('invite', { to: jid }).up();
453
+            });
437 454
 
438 455
             this.xmpp.connection.sendIQ(msgToSend,
439 456
                 () => { }, // eslint-disable-line no-empty-function
440 457
                 e => {
441
-                    logger.error(`Error sending invite for ${jid}`, e);
458
+                    logger.error(`Error sending invite for ${membersToApprove}`, e);
442 459
                 });
443
-        } else {
444
-            logger.error(`Not found member for ${memberRoomJid} in lobby room.`);
445 460
         }
446 461
     }
447 462
 }

正在加载...
取消
保存