Quellcode durchsuchen

fix(chat) add messageId to message events

release-8443
Patrick He vor 1 Jahr
Ursprung
Commit
a97a8dff5a
Es ist kein Account mit der E-Mail-Adresse des Committers verbunden
2 geänderte Dateien mit 12 neuen und 8 gelöschten Zeilen
  1. 6
    6
      JitsiConferenceEventManager.js
  2. 6
    2
      modules/xmpp/ChatRoom.js

+ 6
- 6
JitsiConferenceEventManager.js Datei anzeigen

@@ -368,24 +368,24 @@ JitsiConferenceEventManager.prototype.setupChatRoomListeners = function() {
368 368
         XMPPEvents.MESSAGE_RECEIVED,
369 369
 
370 370
         // eslint-disable-next-line max-params
371
-        (jid, txt, myJid, ts, nick, isGuest) => {
372
-            const id = Strophe.getResourceFromJid(jid);
371
+        (jid, txt, myJid, ts, nick, isGuest, messageId) => {
372
+            const participantId = Strophe.getResourceFromJid(jid);
373 373
 
374 374
             conference.eventEmitter.emit(
375 375
                 JitsiConferenceEvents.MESSAGE_RECEIVED,
376
-                id, txt, ts, nick, isGuest);
376
+                participantId, txt, ts, nick, isGuest, messageId);
377 377
         });
378 378
 
379 379
     chatRoom.addListener(
380 380
         XMPPEvents.PRIVATE_MESSAGE_RECEIVED,
381 381
 
382 382
         // eslint-disable-next-line max-params
383
-        (jid, txt, myJid, ts) => {
384
-            const id = Strophe.getResourceFromJid(jid);
383
+        (jid, txt, myJid, ts, messageId) => {
384
+            const participantId = Strophe.getResourceFromJid(jid);
385 385
 
386 386
             conference.eventEmitter.emit(
387 387
                 JitsiConferenceEvents.PRIVATE_MESSAGE_RECEIVED,
388
-                id, txt, ts);
388
+                participantId, txt, ts, messageId);
389 389
         });
390 390
 
391 391
     chatRoom.addListener(XMPPEvents.PRESENCE_STATUS,

+ 6
- 2
modules/xmpp/ChatRoom.js Datei anzeigen

@@ -3,6 +3,7 @@ import { getLogger } from '@jitsi/logger';
3 3
 import $ from 'jquery';
4 4
 import isEqual from 'lodash.isequal';
5 5
 import { $iq, $msg, $pres, Strophe } from 'strophe.js';
6
+import { v4 as uuidv4 } from 'uuid';
6 7
 
7 8
 import { AUTH_ERROR_TYPES } from '../../JitsiConferenceErrors';
8 9
 import * as JitsiTranscriptionStatus from '../../JitsiTranscriptionStatus';
@@ -1207,9 +1208,12 @@ export default class ChatRoom extends Listenable {
1207 1208
         }
1208 1209
 
1209 1210
         if (txt) {
1211
+
1212
+            const messageId = $(msg).attr('id') || uuidv4();
1213
+
1210 1214
             if (type === 'chat') {
1211 1215
                 this.eventEmitter.emit(XMPPEvents.PRIVATE_MESSAGE_RECEIVED,
1212
-                        from, txt, this.myroomjid, stamp);
1216
+                        from, txt, this.myroomjid, stamp, messageId);
1213 1217
             } else if (type === 'groupchat') {
1214 1218
                 const nickEl = $(msg).find('>nick');
1215 1219
                 let nick;
@@ -1222,7 +1226,7 @@ export default class ChatRoom extends Listenable {
1222 1226
                 // informing that this is probably a message from a guest to the conference (visitor)
1223 1227
                 // a message with explicit name set
1224 1228
                 this.eventEmitter.emit(XMPPEvents.MESSAGE_RECEIVED,
1225
-                    from, txt, this.myroomjid, stamp, nick, Boolean(nick));
1229
+                    from, txt, this.myroomjid, stamp, nick, Boolean(nick), messageId);
1226 1230
             }
1227 1231
         }
1228 1232
     }

Laden…
Abbrechen
Speichern