Mercurial > libervia-backend
diff sat/plugins/plugin_xep_0384.py @ 3969:8e7d5796fb23
plugin XEP-0391: implement XEP-0391 (Jingle Encrypted Transports) + XEP-0396 (JET-OMEMO):
rel 378
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 31 Oct 2022 04:09:34 +0100 |
parents | f461f11ea176 |
children | 5fbdf986670c |
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0384.py Mon Oct 31 04:04:32 2022 +0100 +++ b/sat/plugins/plugin_xep_0384.py Mon Oct 31 04:09:34 2022 +0100 @@ -1630,7 +1630,9 @@ @param client: The client. """ - await self.__prepare_for_profile(cast(str, client.profile)) + await self.get_session_manager( + cast(str, client.profile) + ) async def cmd_omemo_reset( self, @@ -1665,7 +1667,7 @@ bare_jid = mess_data["to"].userhost() - session_manager = await self.__prepare_for_profile(client.profile) + session_manager = await self.get_session_manager(client.profile) devices = await session_manager.get_device_information(bare_jid) for device in devices: @@ -1701,7 +1703,7 @@ else: bare_jids = { entity.userhost() } - session_manager = await self.__prepare_for_profile(client.profile) + session_manager = await self.get_session_manager(client.profile) # At least sort the devices by bare JID such that they aren't listed completely # random @@ -1896,7 +1898,7 @@ return bare_jids - async def __prepare_for_profile(self, profile: str) -> omemo.SessionManager: + async def get_session_manager(self, profile: str) -> omemo.SessionManager: """ @param profile: The profile to prepare for. @return: A session manager instance for this profile. Creates a new instance if @@ -2198,7 +2200,7 @@ )) try: - session_manager = await self.__prepare_for_profile(cast(str, client.profile)) + session_manager = await self.get_session_manager(cast(str, client.profile)) except Exception as e: log.error(f"error while preparing profile for {client.profile}: {e}") # we don't want to block the workflow @@ -2265,7 +2267,7 @@ device_information, __ = await session_manager.get_own_device_information() else: try: - plaintext, device_information = await session_manager.decrypt(message) + plaintext, device_information, __ = await session_manager.decrypt(message) except omemo.MessageNotForUs: # The difference between this being a debug or a warning is whether there # is a body included in the message. Without a body, we can assume that @@ -2584,7 +2586,7 @@ log.debug(f"Plaintext to encrypt: {plaintext}") - session_manager = await self.__prepare_for_profile(client.profile) + session_manager = await self.get_session_manager(client.profile) try: messages, encryption_errors = await session_manager.encrypt( @@ -2702,7 +2704,7 @@ ) return - session_manager = await self.__prepare_for_profile(profile) + session_manager = await self.get_session_manager(profile) await session_manager.update_device_list( namespace,