comparison 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
comparison
equal deleted inserted replaced
4218:c0f3f29377f1 4219:1b5cf2ee1d86
122 encryption_data = content_data["encryption"] = { 122 encryption_data = content_data["encryption"] = {
123 "cipher": cipher, 123 "cipher": cipher,
124 "type": enc_type 124 "type": enc_type
125 } 125 }
126 session_manager = await self._o.get_session_manager(client.profile) 126 session_manager = await self._o.get_session_manager(client.profile)
127 await self._o.download_missing_device_lists(
128 client, self._o.NS_OLDMEMO, {session["peer_jid"]}, session_manager
129 )
127 try: 130 try:
128 messages, encryption_errors = await session_manager.encrypt( 131 messages, encryption_errors = await session_manager.encrypt(
129 frozenset({session["peer_jid"].userhost()}), 132 frozenset({session["peer_jid"].userhost()}),
130 # the value seems to be the commonly used value 133 # the value seems to be the commonly used value
131 { self._o.NS_OLDMEMO: b" " }, 134 { self._o.NS_OLDMEMO: b" " },
132 backend_priority_order=[ self._o.NS_OLDMEMO ], 135 backend_priority_order=[ self._o.NS_OLDMEMO ],
133 identifier = client.jid.userhost() 136 identifier = client.jid.userhost()
134 ) 137 )
135 except Exception as e: 138 except Exception as e:
136 log.error("Can't generate IV and keys: {e}") 139 log.exception("Can't generate IV and keys")
137 raise e 140 raise e
138 message, plain_key_material = next(iter(messages.items())) 141 message, plain_key_material = next(iter(messages.items()))
139 iv, key = message.content.initialization_vector, plain_key_material.key 142 iv, key = message.content.initialization_vector, plain_key_material.key
140 content_data["encryption"].update({ 143 content_data["encryption"].update({
141 "iv": iv, 144 "iv": iv,