From b242ea24bc80fe21ce9a6900e70ba1d62230b3d1 Mon Sep 17 00:00:00 2001 From: mathieui Date: Tue, 2 Feb 2016 20:03:17 +0100 Subject: Fix #3150 (otr and require_encryption) the require_encryption option would not be honored when opening a new tab with a bare JID. --- plugins/otr.py | 11 ++++++++--- 1 file 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'): -- cgit v1.2.3