comparison sat/memory/encryption.py @ 3921:cc2705225778

core (memory/encryption): helper method to get currently utilised e2ee algorithm's namespace: rel 379
author Goffi <goffi@goffi.org>
date Thu, 06 Oct 2022 16:02:05 +0200
parents 8289ac1b34f4
children 524856bd7b19
comparison
equal deleted inserted replaced
3920:993cc8e56aef 3921:cc2705225778
343 None if there is not encryption for this session with this jid 343 None if there is not encryption for this session with this jid
344 """ 344 """
345 if entity.resource: 345 if entity.resource:
346 raise ValueError("Full jid given when expecting bare jid") 346 raise ValueError("Full jid given when expecting bare jid")
347 return self._sessions.get(entity) 347 return self._sessions.get(entity)
348
349 def get_namespace(self, entity: jid.JID) -> Optional[str]:
350 """Helper method to get the current encryption namespace used
351
352 @param entity: get the namespace for this entity must be a bare jid
353 @return: the algorithm namespace currently used in this session, or None if no
354 e2ee is currently used.
355 """
356 session = self.getSession(entity)
357 if session is None:
358 return None
359 return session["plugin"].namespace
348 360
349 def getTrustUI(self, entity_jid, namespace=None): 361 def getTrustUI(self, entity_jid, namespace=None):
350 """Retrieve encryption UI 362 """Retrieve encryption UI
351 363
352 @param entity_jid(jid.JID): get the UI for this entity 364 @param entity_jid(jid.JID): get the UI for this entity