plugin_e2ee: quit _encrypt filter as soon as we seen encrypted tags
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
c4ce439483
commit
cfa1bfc5b2
1 changed files with 8 additions and 9 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue