JC Brand 6 年之前
父节点
当前提交
989ce0f54d
共有 3 个文件被更改,包括 22 次插入9 次删除
  1. 5 0
      CHANGES.md
  2. 9 4
      dist/converse.js
  3. 8 5
      src/converse-notification.js

+ 5 - 0
CHANGES.md

@@ -1,5 +1,10 @@
 # Changelog
 
+## 4.0.1 (Unreleased)
+
+- #1182 MUC occupants without nick or JID created
+- #1184 Notification error when message has no body
+
 ## 4.0.0 (2018-09-07)
 
 ## New Features

+ 9 - 4
dist/converse.js

@@ -71740,11 +71740,16 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
         // the message...
 
 
-        const body = sizzle(`encrypted[xmlns="${Strophe.NS.OMEMO}"]`, message).length ? __('OMEMO Message received') : message.querySelector('body').textContent;
+        const body = sizzle(`encrypted[xmlns="${Strophe.NS.OMEMO}"]`, message).length ? __('OMEMO Message received') : _.get(message.querySelector('body'), 'textContent');
+
+        if (!body) {
+          return;
+        }
+
         const n = new Notification(title, {
-          body: body,
-          lang: _converse.locale,
-          icon: _converse.notification_icon
+          'body': body,
+          'lang': _converse.locale,
+          'icon': _converse.notification_icon
         });
         setTimeout(n.close.bind(n), 5000);
       };

+ 8 - 5
src/converse-notification.js

@@ -169,12 +169,15 @@
                 // the message...
                 const body = sizzle(`encrypted[xmlns="${Strophe.NS.OMEMO}"]`, message).length ?
                              __('OMEMO Message received') :
-                             message.querySelector('body').textContent;
+                             _.get(message.querySelector('body'), 'textContent');
+                if (!body) {
+                    return;
+                }
                 const n = new Notification(title, {
-                        body: body,
-                        lang: _converse.locale,
-                        icon: _converse.notification_icon
-                    });
+                    'body': body,
+                    'lang': _converse.locale,
+                    'icon': _converse.notification_icon
+                });
                 setTimeout(n.close.bind(n), 5000);
             };