Ver código fonte

feat(visitors): Visitors chat. (#2245)

* feat(visitors): Visitors chat.

For messages coming from visitors, which are not in the current room we need to supply a display name.
Mark messages with custom display name as coming from guest.

* feat: Adds a visitors version to conferenceIQ.
master
Дамян Минков 2 anos atrás
pai
commit
b6a5a8d958
Nenhuma conta vinculada ao e-mail do autor do commit

+ 2
- 2
JitsiConferenceEventManager.js Ver arquivo

@@ -395,12 +395,12 @@ JitsiConferenceEventManager.prototype.setupChatRoomListeners = function() {
395 395
         XMPPEvents.MESSAGE_RECEIVED,
396 396
 
397 397
         // eslint-disable-next-line max-params
398
-        (jid, txt, myJid, ts) => {
398
+        (jid, txt, myJid, ts, nick, isGuest) => {
399 399
             const id = Strophe.getResourceFromJid(jid);
400 400
 
401 401
             conference.eventEmitter.emit(
402 402
                 JitsiConferenceEvents.MESSAGE_RECEIVED,
403
-                id, txt, ts);
403
+                id, txt, ts, nick, isGuest);
404 404
         });
405 405
 
406 406
     chatRoom.addListener(

+ 11
- 1
modules/xmpp/ChatRoom.js Ver arquivo

@@ -1159,8 +1159,18 @@ export default class ChatRoom extends Listenable {
1159 1159
                 this.eventEmitter.emit(XMPPEvents.PRIVATE_MESSAGE_RECEIVED,
1160 1160
                         from, txt, this.myroomjid, stamp);
1161 1161
             } else if (type === 'groupchat') {
1162
+                const nickEl = $(msg).find('>nick');
1163
+                let nick;
1164
+
1165
+                if (nickEl.length > 0) {
1166
+                    nick = nickEl.text();
1167
+                }
1168
+
1169
+                // we will fire explicitly that this is a guest(isGuest:true) to the conference
1170
+                // informing that this is probably a message from a guest to the conference (visitor)
1171
+                // a message with explicit name set
1162 1172
                 this.eventEmitter.emit(XMPPEvents.MESSAGE_RECEIVED,
1163
-                        from, txt, this.myroomjid, stamp);
1173
+                    from, txt, this.myroomjid, stamp, nick, Boolean(nick));
1164 1174
             }
1165 1175
         }
1166 1176
     }

+ 3
- 0
modules/xmpp/moderator.js Ver arquivo

@@ -216,6 +216,9 @@ Moderator.prototype._createConferenceIq = function() {
216 216
                 }).up();
217 217
         }
218 218
     }
219
+    elem.c('property', {
220
+        name: 'visitors-version',
221
+        value: 1 }).up();
219 222
 
220 223
     return elem;
221 224
 };

Carregando…
Cancelar
Salvar