Skip to content
Snippets Groups Projects
Commit 76ca8cd8 authored by Philipp Hörist's avatar Philipp Hörist
Browse files

Fetch bundles of own devices on send button press

parent 98f9a0e0
No related branches found
No related tags found
No related merge requests found
......@@ -394,6 +394,24 @@ class OmemoPlugin(GajimPlugin):
def are_keys_missing(self, account, contact_jid):
""" Check DB if keys are missing and query them """
state = self.get_omemo_state(account)
my_jid = gajim.get_jid_from_account(account)
# Fetch Bundles of own other Devices
if my_jid not in self.query_for_bundles:
devices_without_session = state \
.devices_without_sessions(my_jid)
self.query_for_bundles.append(my_jid)
if devices_without_session:
for device_id in devices_without_session:
self.fetch_device_bundle_information(account,
state,
my_jid,
device_id)
# Fetch Bundles of contacts devices
if contact_jid not in self.query_for_bundles:
devices_without_session = state \
......
......@@ -253,12 +253,15 @@ class OmemoState:
my_other_devices = set(self.own_devices) - set({self.own_device_id})
# Encrypt the message key with for each of our own devices
for dev in my_other_devices:
cipher = self.get_session_cipher(from_jid, dev)
if self.isTrusted(cipher) == TRUSTED:
encrypted_keys[dev] = cipher.encrypt(key).serialize()
else:
log.debug('Skipped own Device because Trust is: ' +
str(self.isTrusted(cipher)))
try:
cipher = self.get_session_cipher(from_jid, dev)
if self.isTrusted(cipher) == TRUSTED:
encrypted_keys[dev] = cipher.encrypt(key).serialize()
else:
log.debug('Skipped own Device because Trust is: ' +
str(self.isTrusted(cipher)))
except:
log.warn('Failed to find key for device ' + str(dev))
payload = encrypt(key, iv, plaintext)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment