diff libervia/backend/plugins/plugin_xep_0391.py @ 4219:1b5cf2ee1d86

plugin XEP-0384, XEP-0391: download missing devices list: when a peer jid was not in our roster, devices list was not retrieved, resulting in failed en/decryption. This patch does check it and download missing devices list in necessary. There is no subscription managed yet, so the list won't be updated in case of new devices, this should be addressed at some point.
author Goffi <goffi@goffi.org>
date Tue, 05 Mar 2024 17:31:36 +0100
parents 4b842c1fb686
children 919bdf7768d8
line wrap: on
line diff
--- a/libervia/backend/plugins/plugin_xep_0391.py	Tue Mar 05 17:31:36 2024 +0100
+++ b/libervia/backend/plugins/plugin_xep_0391.py	Tue Mar 05 17:31:36 2024 +0100
@@ -124,6 +124,9 @@
                 "type": enc_type
             }
             session_manager = await self._o.get_session_manager(client.profile)
+            await self._o.download_missing_device_lists(
+                client, self._o.NS_OLDMEMO, {session["peer_jid"]}, session_manager
+            )
             try:
                 messages, encryption_errors = await session_manager.encrypt(
                     frozenset({session["peer_jid"].userhost()}),
@@ -133,7 +136,7 @@
                     identifier = client.jid.userhost()
                 )
             except Exception as e:
-                log.error("Can't generate IV and keys: {e}")
+                log.exception("Can't generate IV and keys")
                 raise e
             message, plain_key_material = next(iter(messages.items()))
             iv, key = message.content.initialization_vector, plain_key_material.key