瀏覽代碼

xmpp: only parse JSON messages when they actually exist

dev1
Saúl Ibarra Corretgé 5 年之前
父節點
當前提交
80ba679eca
共有 1 個文件被更改,包括 12 次插入8 次删除
  1. 12
    8
      modules/xmpp/ChatRoom.js

+ 12
- 8
modules/xmpp/ChatRoom.js 查看文件

1063
                     from, invite.attr('from'), txt, password);
1063
                     from, invite.attr('from'), txt, password);
1064
             }
1064
             }
1065
         }
1065
         }
1066
+
1066
         const jsonMessage = $(msg).find('>json-message').text();
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
         if (txt) {
1083
         if (txt) {

Loading…
取消
儲存