Commit 5c445a02 authored by JC Brand's avatar JC Brand

Don't show headlines from full JID if allow_non_roster_messaging is false

parent 6dfc82da
......@@ -24,8 +24,6 @@
* <body>SORRY FOR THIS ADVERT</body
* </message
*/
test_utils.openControlBox();
test_utils.openContactsPanel(_converse);
sinon.spy(utils, 'isHeadlineMessage');
runs(function () {
var stanza = $msg({
......@@ -46,10 +44,8 @@
});
}));
it("will open and display headline messages", mock.initConverse(function (_converse) {
/*
* <message from='notify.example.com'
/* <message from='notify.example.com'
* to='romeo@im.example.com'
* type='headline'
* xml:lang='en'>
......@@ -62,8 +58,6 @@
* </x>
* </message>
*/
test_utils.openControlBox();
test_utils.openContactsPanel(_converse);
sinon.spy(utils, 'isHeadlineMessage');
runs(function () {
var stanza = $msg({
......@@ -90,5 +84,28 @@
utils.isHeadlineMessage.restore(); // unwraps
});
}));
it("will not show a headline messages from a full JID if allow_non_roster_messaging is false", mock.initConverse(function (_converse) {
_converse.allow_non_roster_messaging = false;
sinon.spy(utils, 'isHeadlineMessage');
runs(function () {
var stanza = $msg({
'type': 'headline',
'from': 'andre5114@jabber.snc.ru/Spark',
'to': 'dummy@localhost',
'xml:lang': 'en'
})
.c('nick').t('gpocy').up()
.c('body').t('Здравствуйте друзья');
_converse.connection._dataRecv(test_utils.createRequest(stanza));
});
waits(250);
runs(function () {
expect(_.without('controlbox', _converse.chatboxviews.keys()).length).toBe(0);
expect(utils.isHeadlineMessage.called).toBeTruthy();
expect(utils.isHeadlineMessage.returned(true)).toBeTruthy();
utils.isHeadlineMessage.restore(); // unwraps
});
}));
});
}));
......@@ -17,24 +17,6 @@
var _ = converse.env._,
utils = converse.env.utils;
var onHeadlineMessage = function (message) {
/* Handler method for all incoming messages of type "headline".
*/
var from_jid = message.getAttribute('from');
var _converse = this.__super__._converse;
if (utils.isHeadlineMessage(message)) {
_converse.chatboxes.create({
'id': from_jid,
'jid': from_jid,
'fullname': from_jid,
'type': 'headline'
}).createMessage(message, undefined, message);
_converse.emit('message', message);
}
return true;
};
converse.plugins.add('converse-headline', {
overrides: {
......@@ -107,10 +89,12 @@
});
var onHeadlineMessage = function (message) {
/* Handler method for all incoming messages of type "headline".
*/
/* Handler method for all incoming messages of type "headline". */
var from_jid = message.getAttribute('from');
if (utils.isHeadlineMessage(message)) {
if (_.includes(from_jid, '@') && !_converse.allow_non_roster_messaging) {
return;
}
_converse.chatboxes.create({
'id': from_jid,
'jid': from_jid,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment