From 989ce0f54dffc9ccca04a49a7294d4a8ea12547c Mon Sep 17 00:00:00 2001 From: JC Brand Date: Mon, 10 Sep 2018 16:21:30 +0200 Subject: [PATCH] Fixes #1184 --- CHANGES.md | 5 +++++ dist/converse.js | 13 +++++++++---- src/converse-notification.js | 13 ++++++++----- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 379930539..f9d0042af 100644 --- a/CHANGES.md +++ b/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 diff --git a/dist/converse.js b/dist/converse.js index c8ba47486..cd96023ce 100644 --- a/dist/converse.js +++ b/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); }; diff --git a/src/converse-notification.js b/src/converse-notification.js index be7423603..fce6dfc0d 100644 --- a/src/converse-notification.js +++ b/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); };