summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime “pep” Buquet <pep@bouah.net>2021-07-18 00:56:11 +0200
committerMaxime “pep” Buquet <pep@bouah.net>2022-03-16 08:09:11 +0100
commitcfa1bfc5b297a2fd01ff794a6976534fe101a40e (patch)
tree3dbdecbe922c7075ca10cfbd4a033a3b1fbf3afc
parentc4ce439483db6fe82b38e30ea8105009005e1184 (diff)
downloadpoezio-cfa1bfc5b297a2fd01ff794a6976534fe101a40e.tar.gz
poezio-cfa1bfc5b297a2fd01ff794a6976534fe101a40e.tar.bz2
poezio-cfa1bfc5b297a2fd01ff794a6976534fe101a40e.tar.xz
poezio-cfa1bfc5b297a2fd01ff794a6976534fe101a40e.zip
plugin_e2ee: quit _encrypt filter as soon as we seen encrypted tags
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
-rw-r--r--poezio/plugin_e2ee.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/poezio/plugin_e2ee.py b/poezio/plugin_e2ee.py
index a1ea1f9e..ba0e6cd7 100644
--- a/poezio/plugin_e2ee.py
+++ b/poezio/plugin_e2ee.py
@@ -444,8 +444,10 @@ class E2EEPlugin(BasePlugin):
for (namespace, tag) in self.encrypted_tags:
tmp = tmp and message.xml.find('{%s}%s' % (namespace, tag)) is not None
has_encrypted_tag = tmp
- if has_encrypted_tag:
- log.debug('Message already contains encrypted tags')
+
+ if has_encrypted_tag:
+ log.debug('Message already contains encrypted tags.')
+ raise NothingToEncrypt()
# Find who to encrypt to. If in a groupchat this can be multiple JIDs.
# It is possible that we are not able to find a jid (e.g., semi-anon
@@ -459,13 +461,10 @@ class E2EEPlugin(BasePlugin):
if tab is None: # Possible message sent directly by the e2ee lib?
log.debug(
'A message we do not have a tab for '
- 'is being sent to \'%s\'. %s. \n%r.',
+ 'is being sent to \'%s\'. \n%r.',
message['to'],
- 'Dropping' if not has_encrypted_tag else '',
message,
)
- if not has_encrypted_tag:
- return None
parent = None
if isinstance(tab, PrivateTab):
@@ -510,10 +509,10 @@ class E2EEPlugin(BasePlugin):
# 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:
+ if not self.stanza_encryption and not has_body:
log.debug(
- '%s plugin: Dropping message as it\'s not already encrypted, '
- 'contains no body, and doesn\'t do stanza encryption',
+ '%s plugin: Dropping message as it contains no body, and '
+ 'doesn\'t do stanza encryption',
self.encryption_name,
)
return None