Commit 4cf48efe authored by lovetox's avatar lovetox

foo

parent b55c563e
......@@ -710,10 +710,11 @@ class OMEMOConnection:
if devices_without_session:
for device_id in devices_without_session:
if self.own_jid in self._bundles:
if device_id in self._bundles[self.own_jid]:
self.fetch_device_bundle_information(self.own_jid,
device_id)
try:
self._bundles[self.own_jid][device_id]:
except KeyError:
self.fetch_device_bundle_information(self.own_jid,
device_id)
# Fetch Bundles of contacts devices
if contact_jid not in self.query_for_bundles:
......@@ -725,10 +726,11 @@ class OMEMOConnection:
if devices_without_session:
for device_id in devices_without_session:
if contact_jid in self._bundles:
if device_id in self._bundles[contact_jid]:
self.fetch_device_bundle_information(contact_jid,
device_id)
try:
self._bundles[contact_jid][device_id]
except KeyError:
self.fetch_device_bundle_information(contact_jid,
device_id)
if contact_jid not in self._bundles:
return False
......
......@@ -23,13 +23,13 @@ class SessionManager:
return self._sm.getDevices(jid)
def get_own_device_id(self):
return self._sm.my_device_id
return self._sm.__my_device_id
def get_own_devices(self):
devices = self._sm.getDevices()['active']
if self._sm.my_device_id not in devices:
if self.get_own_device_id() not in devices:
devices = list(devices)
devices.append(self._sm.my_device_id)
devices.append(self.get_own_device_id())
return devices
def get_devices_without_session(self, jid):
......@@ -50,8 +50,8 @@ class SessionManager:
def decrypt(self, jid, sid, iv, message, payload, prekey):
if prekey:
return self._sm.decryptMessage(jid, sid, iv, message, payload)
return self._sm.decryptPreKeyMessage(jid, sid, iv, message, payload)
return self._sm.decryptPreKeyMessage(jid, sid, iv, message, payload)
return self._sm.decryptMessage(jid, sid, iv, message, payload)
def buid_session(self, jid, device, bundle, callback):
return self._sm.buildSession(jid, device, bundle, callback)
......@@ -79,7 +79,7 @@ class DeviceListAnnouncement(Iq):
def build_omemo_stanza(message_node, msg_dict):
encrypted = message_node.addChild('encrypted', attrs={'xmlns': NS_OMEMO})
encrypted = message_node.addChild('encrypted', attrs={'namespace': NS_OMEMO})
header = encrypted.addChild('header', attrs={'sid': msg_dict['sid']})
for device_id in msg_dict['messages']:
data = msg_dict['messages']['device_id']
......@@ -95,12 +95,12 @@ def build_omemo_stanza(message_node, msg_dict):
b64encode(msg_dict['payload']).decode('utf-8'))
# XEP-0380: Explicit Message Encryption
message_node.addChild('encryption', attrs={'xmlns': NS_EME,
'name': 'OMEMO',
'namespace': NS_OMEMO})
# message_node.addChild('encryption', attrs={'xmlns': NS_EME,
# 'name': 'OMEMO',
# 'namespace': NS_OMEMO})
# Store Hint for MAM
message_node.addChild('store', attrs={'xmlns': NS_HINTS})
message_node.addChild('store', attrs={'namespace': NS_HINTS})
class BundleInformationQuery(Iq):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment