Kaynağa Gözat

Don't carbon copy OTR messages.

JC Brand 10 yıl önce
ebeveyn
işleme
0afa7ec188
3 değiştirilmiş dosya ile 30 ekleme ve 7 silme
  1. 7 1
      converse.js
  2. 6 6
      docs/CHANGES.rst
  3. 17 0
      spec/chatbox.js

+ 7 - 1
converse.js

@@ -1382,7 +1382,13 @@
                 var bare_jid = this.model.get('jid');
                 var message = $msg({from: converse.connection.jid, to: bare_jid, type: 'chat', id: timestamp})
                     .c('body').t(text).up()
-                    .c(ACTIVE, {'xmlns': Strophe.NS.CHATSTATES});
+                    .c(ACTIVE, {'xmlns': Strophe.NS.CHATSTATES}).up();
+
+                if (this.model.get('otr_status') != UNENCRYPTED) {
+                    // OTR messages aren't carbon copied
+                    message.c('private', {'xmlns': 'urn:xmpp:carbons:2'});
+                }
+
                 converse.connection.send(message);
                 if (converse.forward_messages) {
                     // Forward the message, so that other connected resources are also aware of it.

+ 6 - 6
docs/CHANGES.rst

@@ -20,20 +20,20 @@ Changelog
 * #418 Logging out with `auto_reconnect=true` causes reconnection retries [jcbrand]
 * #420 Updated German translation [1st8]
 * #427 Converse.js does not subscribe back to a contact not in the roster. [emmanuel-florent]
-* Bugfix. Manual login doesn't work when only websocket_url is set and not bosh_service_url. [jcbrand]
+* Add offline pretty status to enable translation [thierrytiti]
 * Bugfix. ClearSessions during unload event would throw an error when not logged in. [gbonvehi]
+* Bugfix. Manual login doesn't work when only websocket_url is set and not bosh_service_url. [jcbrand]
 * Bugfix. Wrong callback argument mapping in XmppStatus initialize: fullname is null [thierrytiti]
 * CSS fix: room-info bug on hover after room description loaded [thierrytiti]
+* CSS: Fonts Path: editabable $font-path via sass/variables.scss [thierrytiti]
+* Chat boxes returned by the API now have an `is_chatroom` attribute [jcbrand]
+* Decouple automatic away and XEP-0352 support. [jcbrand]
+* Don't carbon copy OTR messages. [jcbrand]
 * I18N: Autodetection of User Locale if no i18n setting is set. [thierrytiti]
 * Refactored in order to remove the strophe.roster.js dependency. [jcbrand]
 * Refactored the plugin architecture. Add `overrides` convention for
   automatically overriding converse.js's methods and Backbone views and models. [jcbrand]
-* Decouple automatic away and XEP-0352 support. [jcbrand]
-* CSS: Fonts Path: editabable $font-path via sass/variables.scss [thierrytiti]
-* Add offline pretty status to enable translation [thierrytiti]
 * With keepalive, don't send out a presence stanza on each page load [jcbrand]
-* Chat boxes returned by the API now have an `is_chatroom` attribute [jcbrand]
-* Cleanup references to strophe.roster.js [thierrytiti]
 
 0.9.3 (2015-05-01)
 ------------------

+ 17 - 0
spec/chatbox.js

@@ -731,6 +731,23 @@
 
             }, converse));
 
+            describe("An OTR Chat Message", function () {
+
+                it("will not be carbon copied when it's sent out", function () {
+                    var msgtext = "?OTR,1,3,?OTR:AAIDAAAAAAEAAAABAAAAwCQ8HKsag0y0DGKsneo0kzKu1ua5L93M4UKTkCf1I2kbm2RgS5kIxDTxrTj3wVRB+H5Si86E1fKtuBgsDf/bKkGTM0h/49vh5lOD9HkE8cnSrFEn5GN,";
+                    var sender_jid = mock.cur_names[3].replace(/ /g,'.').toLowerCase() + '@localhost';
+                    converse_api.chats.open(sender_jid);
+                    var chatbox = converse.chatboxes.get(sender_jid);
+                    spyOn(converse.connection, 'send');
+                    chatbox.set('otr_status', 1); // Set OTR status to UNVERIFIED, to mock an encrypted session
+                    chatbox.trigger('sendMessageStanza', msgtext);
+                    var $sent = $(converse.connection.send.argsForCall[0][0].tree());
+                    expect($sent.find('body').siblings('private').length).toBe(1);
+                    expect($sent.find('private').length).toBe(1);
+                    expect($sent.find('private').attr('xmlns')).toBe('urn:xmpp:carbons:2');
+                });
+            });
+
             describe("A Chat Status Notification", $.proxy(function () {
 
                 it("does not open automatically if a chat state notification is received", $.proxy(function () {