From 968f8bb223db971e9f8f03e2a5253a99a090597b Mon Sep 17 00:00:00 2001 From: JC Brand Date: Sat, 19 Apr 2014 06:18:17 +0200 Subject: [PATCH] Add new configuration setting "forward_messages". What was before default behavior is now optional and disabled by default. --- converse.js | 19 +++++++++++-------- docs/CHANGES.rst | 8 +++++--- docs/source/index.rst | 15 +++++++++++++++ 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/converse.js b/converse.js index a6c9691b7..871759d91 100644 --- a/converse.js +++ b/converse.js @@ -153,6 +153,7 @@ this.debug = false; this.default_box_height = 324; // The default height, in pixels, for the control box, chat boxes and chatrooms. this.expose_rid_and_sid = false; + this.forward_messages = false; this.hide_muc_server = false; this.i18n = locales.en; this.prebind = false; @@ -184,6 +185,7 @@ 'debug', 'default_box_height', 'expose_rid_and_sid', + 'forward_messages', 'fullname', 'hide_muc_server', 'i18n', @@ -1039,15 +1041,15 @@ var message = $msg({from: converse.connection.jid, to: bare_jid, type: 'chat', id: timestamp}) .c('body').t(text).up() .c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}); - // Forward the message, so that other connected resources are also aware of it. - // TODO: Forward the message only to other connected resources (inside the browser) - var forwarded = $msg({to:converse.bare_jid, type:'chat', id:timestamp}) - .c('forwarded', {xmlns:'urn:xmpp:forward:0'}) - .c('delay', {xmns:'urn:xmpp:delay',stamp:timestamp}).up() - .cnode(message.tree()); - converse.connection.send(message); - converse.connection.send(forwarded); + if (converse.forward_messages) { + // Forward the message, so that other connected resources are also aware of it. + var forwarded = $msg({to:converse.bare_jid, type:'chat', id:timestamp}) + .c('forwarded', {xmlns:'urn:xmpp:forward:0'}) + .c('delay', {xmns:'urn:xmpp:delay',stamp:timestamp}).up() + .cnode(message.tree()); + converse.connection.send(forwarded); + } }, sendMessage: function (text) { @@ -2991,6 +2993,7 @@ removeRosterItemView: function (item) { if (this.get(item.id)) { this.get(item.id).remove(); + this.render(); } return this; }, diff --git a/docs/CHANGES.rst b/docs/CHANGES.rst index 353b57b2a..f355816d8 100644 --- a/docs/CHANGES.rst +++ b/docs/CHANGES.rst @@ -6,13 +6,15 @@ Changelog * Chat boxes and rooms can now be resized vertically. [jcbrand] * Chat boxes and rooms can be minimized. [jcbrand] -* Upgraded many dependencies to their latest versions. [jcrand] +* Upgraded many dependencies to their latest versions. [jcbrand] +* Add new configuration setting `forward_messages `_ + Message forwarding was before default behavior but is now optional (and disabled by default). [jcbrand] 0.7.4 (2014-03-05) ------------------ .. note:: This release contains an important security fix. - Thanks to Renaud Dubourguais from `Synacktiv http://synacktiv.com`_ for reporting the vulnerability. + Thanks to Renaud Dubourguais from `Synacktiv `_ for reporting the vulnerability. * #125 Bugfix: crypto dependencies loaded in wrong order [jcbrand] * Bugfix: action messages (i.e. /me) didn't work in OTR mode. [jcbrand] @@ -132,7 +134,7 @@ versions of the 0.6 branch. * Bugfix. The remove icon wasn't appearing in the contacts roster. [jcbrand] * Bugfix. With auto_subscribe=True, the "Pending Contacts" header didn't disappear -after a new user was accepted. [jcbrand] + after a new user was accepted. [jcbrand] 0.6.1 (2013-08-28) ------------------ diff --git a/docs/source/index.rst b/docs/source/index.rst index 386445661..adfe6c48b 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -971,6 +971,8 @@ If set to true, debugging output will be logged to the browser console. expose_rid_and_sid ------------------ +Default = ``false`` + Allow the prebind tokens, RID (request ID) and SID (session ID), to be exposed globally via the API. This allows other scripts served on the same page to use these values. @@ -978,6 +980,19 @@ these values. *Beware*: a malicious script could use these tokens to assume your identity and inject fake chat messages. +forward_messages +---------------- + +Default = ``false`` + +If set to ``true``, sent messages will also be forwarded to other connected +XMPP resources (e.g. chat clients) of the same user. + +This is useful for example if converse.js is running in multiple tabs of the +browser and you want sent messages to appear in all of them. + +See also `XEP 0297: Stanza Forwarding `_ + fullname --------