summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2016-02-02 20:03:17 +0100
committermathieui <mathieui@mathieui.net>2016-02-02 20:05:18 +0100
commitb242ea24bc80fe21ce9a6900e70ba1d62230b3d1 (patch)
tree73dc8b489a2ce267aac09f2335f0de76a067dada
parentdd992600f3f604e34c82cf55dd99662b66e2158c (diff)
downloadpoezio-b242ea24bc80fe21ce9a6900e70ba1d62230b3d1.tar.gz
poezio-b242ea24bc80fe21ce9a6900e70ba1d62230b3d1.tar.bz2
poezio-b242ea24bc80fe21ce9a6900e70ba1d62230b3d1.tar.xz
poezio-b242ea24bc80fe21ce9a6900e70ba1d62230b3d1.zip
Fix #3150 (otr and require_encryption)
the require_encryption option would not be honored when opening a new tab with a bare JID.
-rw-r--r--plugins/otr.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/plugins/otr.py b/plugins/otr.py
index 8b961299..12dd1877 100644
--- a/plugins/otr.py
+++ b/plugins/otr.py
@@ -541,9 +541,9 @@ class Plugin(BasePlugin):
require = self.config.get_by_tabname('require_encryption',
jid, default=False)
flags['REQUIRE_ENCRYPTION'] = require
- logging_policy = self.config.get_by_tabname('log', jid, default='false').lower()
+ logging_policy = self.config.get_by_tabname('log', jid, default=False)
self.contexts[jid] = PoezioContext(self.account, jid, self.core.xmpp, self.core)
- self.contexts[jid].log = 1 if logging_policy != 'false' else 0
+ self.contexts[jid].log = 1 if logging_policy else 0
self.contexts[jid].flags = flags
return self.contexts[jid]
@@ -756,11 +756,16 @@ class Plugin(BasePlugin):
'jid': name,
}
- ctx = self.contexts.get(name)
+ ctx = None
+ default_ctx = self.get_context(name)
+
if isinstance(tab, DynamicConversationTab) and not tab.locked_resource:
log.debug('Unlocked tab %s found, falling back to the first encrypted chat we find.', name)
ctx = self.find_encrypted_context_with_matching(jid.bare)
+ if ctx is None:
+ ctx = default_ctx
+
if ctx and ctx.state == STATE_ENCRYPTED:
ctx.sendMessage(0, msg['body'].encode('utf-8'))
if not tab.send_chat_state('active'):