From 5500e771a427245d3d02eb39307c0e2dfdc950ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Fri, 28 Jun 2019 00:14:57 +0200 Subject: e2ee-api: Add replace_body_with_eme parameter to the class 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 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/poezio/plugin_e2ee.py b/poezio/plugin_e2ee.py index e0a28dba..b2afe867 100644 --- a/poezio/plugin_e2ee.py +++ b/poezio/plugin_e2ee.py @@ -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 for example, some use a - # different element like and thus 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 -- cgit v1.2.3