From c4ce439483db6fe82b38e30ea8105009005e1184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Sun, 18 Jul 2021 00:16:07 +0200 Subject: plugin_e2ee: allow normal message to pass through again when not encrypting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- poezio/plugin_e2ee.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/poezio/plugin_e2ee.py b/poezio/plugin_e2ee.py index 673ea728..a1ea1f9e 100644 --- a/poezio/plugin_e2ee.py +++ b/poezio/plugin_e2ee.py @@ -505,6 +505,9 @@ class E2EEPlugin(BasePlugin): has_body = message.xml.find('{%s}%s' % (JCLIENT_NS, 'body')) is not None + if not self._encryption_enabled(tab.jid): + raise NothingToEncrypt() + # Drop all messages that don't contain a body if the plugin doesn't do # Stanza Encryption if not self.stanza_encryption and not has_encrypted_tag and not has_body: @@ -515,18 +518,14 @@ class E2EEPlugin(BasePlugin): ) return None - if tab and not has_encrypted_tag: - if not self._encryption_enabled(tab.jid): - raise NothingToEncrypt() - - # Call the enabled encrypt method - func = self._enabled_tabs[tab.jid] - if iscoroutinefunction(func): - # pylint: disable=unexpected-keyword-arg - await func(message, jids, tab, passthrough=True) - else: - # pylint: disable=unexpected-keyword-arg - func(message, jids, tab, passthrough=True) + # Call the enabled encrypt method + func = self._enabled_tabs[tab.jid] + if iscoroutinefunction(func): + # pylint: disable=unexpected-keyword-arg + await func(message, jids, tab, passthrough=True) + else: + # pylint: disable=unexpected-keyword-arg + func(message, jids, tab, passthrough=True) if has_body: # Only add EME tag if the message has a body. -- cgit v1.2.3