New event messageNotification

This commit is contained in:
JC Brand 2018-12-06 13:55:28 +01:00
parent a2441545db
commit aa730b5976
3 changed files with 19 additions and 0 deletions

2
dist/converse.js vendored
View File

@ -55920,6 +55920,8 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
return false;
}
_converse.api.emit('messageNotification', message);
_converse.playSoundNotification();
_converse.showMessageNotification(message);

View File

@ -259,6 +259,22 @@ as a `message` attribute which refers to the Message model.
// The original chatbox is at `data.chatbox`.
});
messageNotification
~~~~~~~~~~~~~~~~~~~
Emitted just before an HTML5 message notification will be sent out.
.. code-block:: javascript
_converse.api.listen.on('messageNotification', stanza => {
const body = sizzle(`encrypted[xmlns="${Strophe.NS.OMEMO}"]`, message).length ?
__('OMEMO Message received') :
_.get(message.querySelector('body'), 'textContent');
alert(body);
});
messageSend
~~~~~~~~~~~

View File

@ -261,6 +261,7 @@ converse.plugins.add('converse-notification', {
if (!_converse.shouldNotifyOfMessage(message)) {
return false;
}
_converse.api.emit('messageNotification', message);
_converse.playSoundNotification();
_converse.showMessageNotification(message);
};