Selaa lähdekoodia

xmpp: only parse JSON messages when they actually exist

dev1
Saúl Ibarra Corretgé 5 vuotta sitten
vanhempi
commit
80ba679eca
1 muutettua tiedostoa jossa 12 lisäystä ja 8 poistoa
  1. 12
    8
      modules/xmpp/ChatRoom.js

+ 12
- 8
modules/xmpp/ChatRoom.js Näytä tiedosto

@@ -1063,17 +1063,21 @@ export default class ChatRoom extends Listenable {
1063 1063
                     from, invite.attr('from'), txt, password);
1064 1064
             }
1065 1065
         }
1066
+
1066 1067
         const jsonMessage = $(msg).find('>json-message').text();
1067
-        const parsedJson = this.xmpp.tryParseJSONAndVerify(jsonMessage);
1068 1068
 
1069
-        // We emit this event if the message is a valid json, and is not
1070
-        // delivered after a delay, i.e. stamp is undefined.
1071
-        // e.g. - subtitles should not be displayed if delayed.
1072
-        if (parsedJson && stamp === undefined) {
1073
-            this.eventEmitter.emit(XMPPEvents.JSON_MESSAGE_RECEIVED,
1074
-                from, parsedJson);
1069
+        if (jsonMessage) {
1070
+            const parsedJson = this.xmpp.tryParseJSONAndVerify(jsonMessage);
1075 1071
 
1076
-            return;
1072
+            // We emit this event if the message is a valid json, and is not
1073
+            // delivered after a delay, i.e. stamp is undefined.
1074
+            // e.g. - subtitles should not be displayed if delayed.
1075
+            if (parsedJson && stamp === undefined) {
1076
+                this.eventEmitter.emit(XMPPEvents.JSON_MESSAGE_RECEIVED,
1077
+                    from, parsedJson);
1078
+
1079
+                return;
1080
+            }
1077 1081
         }
1078 1082
 
1079 1083
         if (txt) {

Loading…
Peruuta
Tallenna