From 7b9e785c13c3b92894603d4ad10f36d99acd5fb2 Mon Sep 17 00:00:00 2001 From: Goffi Date: Sat, 15 Oct 2022 20:38:33 +0200 Subject: [PATCH] plugin OXPS, XEP-0060: indicate which items were e2ee: the new `encryption` key is added to `getItems` metadata if items were e2ee, it contains a map from item ID to encryption metadata. rel 380 --- sat/plugins/plugin_sec_oxps.py | 1 + sat/plugins/plugin_xep_0060.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/sat/plugins/plugin_sec_oxps.py b/sat/plugins/plugin_sec_oxps.py index 144ab84f..37db511f 100644 --- a/sat/plugins/plugin_sec_oxps.py +++ b/sat/plugins/plugin_sec_oxps.py @@ -736,6 +736,7 @@ class PubsubEncryption: decrypted_elt = xml_tools.parse(decrypted) item.children.clear() item.addChild(decrypted_elt) + extra.setdefault("encrypted", {})[item["id"]] = {"type": NS_OXPS} async def _message_received_trigger( self, diff --git a/sat/plugins/plugin_xep_0060.py b/sat/plugins/plugin_xep_0060.py index a05e92b1..9d55b087 100644 --- a/sat/plugins/plugin_xep_0060.py +++ b/sat/plugins/plugin_xep_0060.py @@ -854,6 +854,9 @@ class XEP_0060(object): # normally we have a strict equality here but XEP-0059 states # that index MAY be approximative, so just in case… metadata["complete"] = index + len(items) >= count + # encrypted metadata can be added by plugins in XEP-0060_items trigger + if "encrypted" in extra: + metadata["encrypted"] = extra["encrypted"] return (items, metadata)