changeset d47d8c0e09f5 in /home/hg/repos/gajim-plugins
author: lovetox <[email protected]>
branches:
details:gajim-plugins?cmd=changeset;node=d47d8c0e09f5
description: Fetch bundles of own devices on send button press
diffstat:
omemo/__init__.py | 18 ++++++++++++++++++
omemo/omemo/state.py | 15 +++++++++------
2 files changed, 27 insertions(+), 6 deletions(-)
diffs (53 lines):
diff -r 96ad8a0dd4f3 -r d47d8c0e09f5 omemo/__init__.py
--- a/omemo/__init__.py Wed Aug 03 22:26:35 2016 +0200
+++ b/omemo/__init__.py Thu Aug 04 22:15:36 2016 +0200
@@ -394,6 +394,24 @@
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 \
diff -r 96ad8a0dd4f3 -r d47d8c0e09f5 omemo/omemo/state.py
--- a/omemo/omemo/state.py Wed Aug 03 22:26:35 2016 +0200
+++ b/omemo/omemo/state.py Thu Aug 04 22:15:36 2016 +0200
@@ -253,12 +253,15 @@
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)
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits