summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime “pep” Buquet <pep@bouah.net>2019-06-28 00:14:57 +0200
committerMaxime “pep” Buquet <pep@bouah.net>2019-07-01 19:42:45 +0200
commit5500e771a427245d3d02eb39307c0e2dfdc950ff (patch)
tree29825157416755cffb0f94d59b5cfa286f08dbe8
parentfdb5baeb0c1db6dcd2a97fed7eb4037008660119 (diff)
downloadpoezio-5500e771a427245d3d02eb39307c0e2dfdc950ff.tar.gz
poezio-5500e771a427245d3d02eb39307c0e2dfdc950ff.tar.bz2
poezio-5500e771a427245d3d02eb39307c0e2dfdc950ff.tar.xz
poezio-5500e771a427245d3d02eb39307c0e2dfdc950ff.zip
e2ee-api: Add replace_body_with_eme parameter to the class
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
-rw-r--r--poezio/plugin_e2ee.py12
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