From 11f16fc2d0107b4c1d03b8460b17a5fdee1efb84 Mon Sep 17 00:00:00 2001 From: Goffi Date: Thu, 6 Oct 2022 16:02:05 +0200 Subject: [PATCH] core (memory/encryption): helper method to get currently utilised e2ee algorithm's namespace: rel 379 --- sat/memory/encryption.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sat/memory/encryption.py b/sat/memory/encryption.py index 4e9d1095..bfdff715 100644 --- a/sat/memory/encryption.py +++ b/sat/memory/encryption.py @@ -346,6 +346,18 @@ class EncryptionHandler: raise ValueError("Full jid given when expecting bare jid") return self._sessions.get(entity) + def get_namespace(self, entity: jid.JID) -> Optional[str]: + """Helper method to get the current encryption namespace used + + @param entity: get the namespace for this entity must be a bare jid + @return: the algorithm namespace currently used in this session, or None if no + e2ee is currently used. + """ + session = self.getSession(entity) + if session is None: + return None + return session["plugin"].namespace + def getTrustUI(self, entity_jid, namespace=None): """Retrieve encryption UI