diff options
-rw-r--r-- | poezio/plugin_e2ee.py | 12 |
1 files 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 <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 |