Commit 5500e771 authored by Maxime Buquet's avatar Maxime Buquet

e2ee-api: Add replace_body_with_eme parameter to the class

Signed-off-by: Maxime Buquet's avatarMaxime “pep” Buquet <pep@bouah.net>
parent fdb5baeb
......@@ -41,12 +41,7 @@ class E2EEPlugin(BasePlugin):
stanza_encryption = False
# Whitelist applied to messages when `stanza_encryption` is False.
# This might need to be changed depending on the encryption mechanism.
# Some encrypt directly content in <body/> for example, some use a
# different element like <payload/> and thus <body/> is a generic EME
# message.
tag_whitelist = list(map(lambda x: '{%s}%s' % (x[0], x[1]), [
(JCLIENT_NS, 'body'),
(EME_NS, EME_TAG),
(HINTS_NS, 'store'),
(HINTS_NS, 'no-copy'),
......@@ -54,6 +49,8 @@ class E2EEPlugin(BasePlugin):
(HINTS_NS, 'no-permanent-store'),
]))
replace_body_with_eme = True
# At least one of encryption_name and encryption_short_name must be set
encryption_name = None # type: Optional[str]
encryption_short_name = None # type: Optional[str]
......@@ -184,6 +181,11 @@ class E2EEPlugin(BasePlugin):
if elem.tag not in self.tag_whitelist:
message.xml.remove(elem)
if self.replace_body_with_eme:
body = message.xml.find('{%s}%s' % (JCLIENT_NS, 'body'))
if body is not None:
self.core.xmpp['xep_0380'].replace_body_with_eme(message)
log.debug('Decrypted %s message: %r', self.encryption_name, message['body'])
return None
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment