Sfoglia il codice sorgente

Merge branch 'otr-by-default' of git://github.com/Aupajo/converse.js into Apajo-otr-by-default

Conflicts:
	converse.js

Fixes #102
JC Brand 11 anni fa
parent
commit
94c135a6d8
3 ha cambiato i file con 16 aggiunte e 2 eliminazioni
  1. 7 2
      converse.js
  2. 1 0
      docs/CHANGES.rst
  3. 8 0
      docs/source/index.rst

+ 7 - 2
converse.js

@@ -147,6 +147,7 @@
         this.show_call_button = false;
         this.show_call_button = false;
         this.show_emoticons = true;
         this.show_emoticons = true;
         this.show_toolbar = true;
         this.show_toolbar = true;
+        this.use_otr_by_default = false;
         this.use_vcards = true;
         this.use_vcards = true;
         this.xhr_custom_status = false;
         this.xhr_custom_status = false;
         this.xhr_custom_status_url = '';
         this.xhr_custom_status_url = '';
@@ -179,6 +180,7 @@
             'show_only_online_users',
             'show_only_online_users',
             'show_toolbar',
             'show_toolbar',
             'sid',
             'sid',
+            'use_otr_by_default',
             'use_vcards',
             'use_vcards',
             'xhr_custom_status',
             'xhr_custom_status',
             'xhr_custom_status_url',
             'xhr_custom_status_url',
@@ -189,6 +191,9 @@
         // Only allow OTR if we have the capability
         // Only allow OTR if we have the capability
         this.allow_otr = this.allow_otr && HAS_CRYPTO;
         this.allow_otr = this.allow_otr && HAS_CRYPTO;
 
 
+        // Only use OTR by default if allow OTR is enabled to begin with
+        this.use_otr_by_default = this.use_otr_by_default && this.allow_otr;
+
         // Translation machinery
         // Translation machinery
         // ---------------------
         // ---------------------
         var __ = $.proxy(function (str) {
         var __ = $.proxy(function (str) {
@@ -928,11 +933,11 @@
                 this.updateVCard();
                 this.updateVCard();
                 this.$el.appendTo(converse.chatboxesview.$el);
                 this.$el.appendTo(converse.chatboxesview.$el);
                 this.render().show().model.messages.fetch({add: true});
                 this.render().show().model.messages.fetch({add: true});
+
                 if (this.model.get('status')) {
                 if (this.model.get('status')) {
                     this.showStatusMessage(this.model.get('status'));
                     this.showStatusMessage(this.model.get('status'));
                 }
                 }
-
-                if (_.contains([UNVERIFIED, VERIFIED], this.model.get('otr_status'))) {
+                if ((_.contains([UNVERIFIED, VERIFIED], this.model.get('otr_status'))) || converse.use_otr_by_default) {
                     this.model.initiateOTR();
                     this.model.initiateOTR();
                 }
                 }
             },
             },

+ 1 - 0
docs/CHANGES.rst

@@ -5,6 +5,7 @@ Unreleased
 ----------
 ----------
 
 
 * #93 Add API methods exposing the RID and SID values. Can be disabled. [jcbrand]
 * #93 Add API methods exposing the RID and SID values. Can be disabled. [jcbrand]
+* #102 Option to enable OTR by default. [Aupajo]
 * #103 Option to display a call button in the chatbox toolbar, to allow third-party libraries to provide a calling feature. [Aupajo]
 * #103 Option to display a call button in the chatbox toolbar, to allow third-party libraries to provide a calling feature. [Aupajo]
 * #108 Japanese Translations [mako09]
 * #108 Japanese Translations [mako09]
 * #111 OTR not working when using converse.js with prebinding. [jseidl, jcbrand]
 * #111 OTR not working when using converse.js with prebinding. [jseidl, jcbrand]

+ 8 - 0
docs/source/index.rst

@@ -896,6 +896,14 @@ Default = ``false``
 If set to ``true``, only online users will be shown in the contacts roster.
 If set to ``true``, only online users will be shown in the contacts roster.
 Users with any other status (e.g. away, busy etc.) will not be shown.
 Users with any other status (e.g. away, busy etc.) will not be shown.
 
 
+use_otr_by_default
+------------------
+
+Default = ``false``
+
+If set to ``true``, Converse.js will automatically try to initiate an OTR (off-the-record)
+encrypted chat session every time you open a chat box.
+
 use_vcards
 use_vcards
 ----------
 ----------