Bladeren bron

feat: Moves moderator to xmpp.

release-8443
damencho 2 jaren geleden
bovenliggende
commit
121274c834

+ 4
- 4
JitsiConference.js Bestand weergeven

@@ -860,7 +860,7 @@ JitsiConference.prototype.getAuthLogin = function() {
860 860
  * Check if external authentication is enabled for this conference.
861 861
  */
862 862
 JitsiConference.prototype.isExternalAuthEnabled = function() {
863
-    return this.room && this.room.moderator.isExternalAuthEnabled();
863
+    return this.room && this.room.xmpp.moderator.isExternalAuthEnabled();
864 864
 };
865 865
 
866 866
 /**
@@ -877,9 +877,9 @@ JitsiConference.prototype.getExternalAuthUrl = function(urlForPopup) {
877 877
             return;
878 878
         }
879 879
         if (urlForPopup) {
880
-            this.room.moderator.getPopupLoginUrl(this.room.roomjid, resolve, reject);
880
+            this.room.xmpp.moderator.getPopupLoginUrl(this.room.roomjid, resolve, reject);
881 881
         } else {
882
-            this.room.moderator.getLoginUrl(this.room.roomjid, resolve, reject);
882
+            this.room.xmpp.moderator.getLoginUrl(this.room.roomjid, resolve, reject);
883 883
         }
884 884
     });
885 885
 };
@@ -2569,7 +2569,7 @@ JitsiConference.prototype.stopRecording = function(sessionID) {
2569 2569
  * Returns true if the SIP calls are supported and false otherwise
2570 2570
  */
2571 2571
 JitsiConference.prototype.isSIPCallingSupported = function() {
2572
-    return this.room?.moderator?.isSipGatewayEnabled() ?? false;
2572
+    return this.room?.xmpp?.moderator?.isSipGatewayEnabled() ?? false;
2573 2573
 };
2574 2574
 
2575 2575
 /**

+ 2
- 2
authenticateAndUpgradeRole.js Bestand weergeven

@@ -99,7 +99,7 @@ export default function authenticateAndUpgradeRole({
99 99
                     onCreateResource
100 100
                 );
101 101
 
102
-                room.moderator.authenticate(room.roomjid)
102
+                room.xmpp.moderator.authenticate(room.roomjid)
103 103
                     .then(() => {
104 104
                         xmpp && xmpp.disconnect();
105 105
 
@@ -109,7 +109,7 @@ export default function authenticateAndUpgradeRole({
109 109
 
110 110
                         // At this point we should have the new session ID
111 111
                         // stored in the settings. Send a new conference IQ.
112
-                        this.room.moderator.sendConferenceRequest().finally(resolve);
112
+                        this.room.xmpp.moderator.sendConferenceRequest().finally(resolve);
113 113
                     })
114 114
                     .catch(({ error, message }) => {
115 115
                         xmpp.disconnect();

+ 4
- 6
modules/xmpp/ChatRoom.js Bestand weergeven

@@ -19,7 +19,6 @@ import BreakoutRooms from './BreakoutRooms';
19 19
 import Lobby from './Lobby';
20 20
 import RoomMetadata from './RoomMetadata';
21 21
 import XmppConnection from './XmppConnection';
22
-import Moderator from './moderator';
23 22
 
24 23
 const logger = getLogger(__filename);
25 24
 
@@ -170,9 +169,8 @@ export default class ChatRoom extends Listenable {
170 169
         this.focusMucJid = null;
171 170
         this.noBridgeAvailable = false;
172 171
         this.options = options || {};
173
-        this.moderator = new Moderator(this.xmpp, xmpp.options);
174 172
 
175
-        this.eventsForwarder = new EventEmitterForwarder(this.moderator, this.eventEmitter);
173
+        this.eventsForwarder = new EventEmitterForwarder(this.xmpp.moderator, this.eventEmitter);
176 174
         this.eventsForwarder.forward(AuthenticationEvents.IDENTITY_UPDATED, AuthenticationEvents.IDENTITY_UPDATED);
177 175
         this.eventsForwarder.forward(XMPPEvents.REDIRECTED, XMPPEvents.REDIRECTED);
178 176
         this.eventsForwarder.forward(XMPPEvents.AUTHENTICATION_REQUIRED, XMPPEvents.AUTHENTICATION_REQUIRED);
@@ -234,7 +232,7 @@ export default class ChatRoom extends Listenable {
234 232
             const preJoin
235 233
                 = this.options.disableFocus
236 234
                     ? Promise.resolve()
237
-                    : this.moderator.sendConferenceRequest(this.roomjid);
235
+                    : this.xmpp.moderator.sendConferenceRequest(this.roomjid);
238 236
 
239 237
             preJoin.then(() => {
240 238
                 this.sendPresence(true);
@@ -279,7 +277,7 @@ export default class ChatRoom extends Listenable {
279 277
             }
280 278
 
281 279
             // send the machineId with the initial presence
282
-            if (this.moderator.targetUrl) {
280
+            if (this.xmpp.moderator.targetUrl) {
283 281
                 pres.c('billingid').t(Settings.machineId).up();
284 282
             }
285 283
 
@@ -522,7 +520,7 @@ export default class ChatRoom extends Listenable {
522 520
         const jid = mucUserItem && mucUserItem.getAttribute('jid');
523 521
 
524 522
         member.jid = jid;
525
-        member.isFocus = this.moderator.isFocusJid(jid);
523
+        member.isFocus = this.xmpp.moderator.isFocusJid(jid);
526 524
         member.isHiddenDomain
527 525
             = jid && jid.indexOf('@') > 0
528 526
                 && this.options.hiddenDomain

+ 7
- 0
modules/xmpp/ChatRoom.spec.js Bestand weergeven

@@ -3,6 +3,7 @@ import { $pres } from 'strophe.js';
3 3
 import { XMPPEvents } from '../../service/xmpp/XMPPEvents';
4 4
 
5 5
 import ChatRoom, { parser } from './ChatRoom';
6
+import Moderator from './moderator';
6 7
 
7 8
 // This rule makes creating the xml elements take up way more
8 9
 // space than necessary.
@@ -138,6 +139,9 @@ describe('ChatRoom', () => {
138 139
 
139 140
         beforeEach(() => {
140 141
             const xmpp = {
142
+                moderator: new Moderator({
143
+                    options: {}
144
+                }),
141 145
                 options: {},
142 146
                 addListener: () => {} // eslint-disable-line no-empty-function
143 147
             };
@@ -350,6 +354,9 @@ describe('ChatRoom', () => {
350 354
 
351 355
         beforeEach(() => {
352 356
             const xmpp = {
357
+                moderator: new Moderator({
358
+                    options: {}
359
+                }),
353 360
                 options: {},
354 361
                 addListener: () => {} // eslint-disable-line no-empty-function
355 362
             };

+ 4
- 5
modules/xmpp/moderator.js Bestand weergeven

@@ -46,14 +46,13 @@ export default class Moderator extends Listenable {
46 46
     /**
47 47
      * Constructs moderator.
48 48
      * @param xmpp The xmpp.
49
-     * @param options The options.
50 49
      */
51
-    constructor(xmpp, options) {
50
+    constructor(xmpp) {
52 51
         super();
53 52
 
54 53
         this.getNextTimeout = createExpBackoffTimer(1000);
55 54
         this.getNextErrorTimeout = createExpBackoffTimer(1000);
56
-        this.options = options;
55
+        this.options = xmpp.options;
57 56
 
58 57
         // External authentication stuff
59 58
         this.externalAuthEnabled = false;
@@ -82,8 +81,8 @@ export default class Moderator extends Listenable {
82 81
         // and responses from conference requests.
83 82
         this.focusUserJids = new Set();
84 83
 
85
-        if (options.focusUserJid) {
86
-            this.focusUserJids.add(options.focusUserJid);
84
+        if (this.options.focusUserJid) {
85
+            this.focusUserJids.add(this.options.focusUserJid);
87 86
         }
88 87
 
89 88
         // FIXME: Message listener that talks to POPUP window

+ 3
- 0
modules/xmpp/xmpp.js Bestand weergeven

@@ -17,6 +17,7 @@ import RandomUtil from '../util/RandomUtil';
17 17
 
18 18
 import Caps, { parseDiscoInfo } from './Caps';
19 19
 import XmppConnection from './XmppConnection';
20
+import Moderator from './moderator';
20 21
 import MucConnectionPlugin from './strophe.emuc';
21 22
 import JingleConnectionPlugin from './strophe.jingle';
22 23
 import initStropheLogger from './strophe.logger';
@@ -164,6 +165,8 @@ export default class XMPP extends Listenable {
164 165
             shard: options.deploymentInfo.shard
165 166
         });
166 167
 
168
+        this.moderator = new Moderator(this);
169
+
167 170
         // forwards the shard changed event
168 171
         this.connection.on(XmppConnection.Events.CONN_SHARD_CHANGED, () => {
169 172
             /* eslint-disable camelcase */

Laden…
Annuleren
Opslaan