Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim-plugins.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Hörist <forenjunkie@chello.at>2017-03-01 00:18:39 +0300
committerPhilipp Hörist <forenjunkie@chello.at>2017-03-01 00:18:39 +0300
commitbc2731364b13427355fb5188138be89ec7ad7bc7 (patch)
treeb9e48b5565b829058bb8c1090b2eee9d5a033398 /omemo/omemoplugin.py
parent7779cfce4bfdd8c5568932bb2d591d3f9346f81a (diff)
[omemo] Only publish own deviceid if request fails
Diffstat (limited to 'omemo/omemoplugin.py')
-rw-r--r--omemo/omemoplugin.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/omemo/omemoplugin.py b/omemo/omemoplugin.py
index 49fc012..45ce5bb 100644
--- a/omemo/omemoplugin.py
+++ b/omemo/omemoplugin.py
@@ -764,19 +764,25 @@ class OmemoPlugin(GajimPlugin):
return True
@log_calls('OmemoPlugin')
- def publish_own_devices_list(self, account):
- """ Check if the passed event is a device list update and store the new
- device ids.
+ def publish_own_devices_list(self, account, new=False):
+ """ Get all currently known own active device ids and publish them
Parameters
----------
account : str
the account name
+
+ new : bool
+ if True, a devicelist with only one
+ (the current id of this instance) device id is pushed
"""
state = self.get_omemo_state(account)
- devices_list = state.own_devices
- devices_list.append(state.own_device_id)
- devices_list = list(set(devices_list))
+ if new:
+ devices_list = [state.own_device_id]
+ else:
+ devices_list = state.own_devices
+ devices_list.append(state.own_device_id)
+ devices_list = list(set(devices_list))
state.set_own_devices(devices_list)
log.debug(account + ' => Publishing own Devices: ' + str(
@@ -1047,7 +1053,7 @@ class OmemoPlugin(GajimPlugin):
devices_list = list(set(unpack_device_list_update(stanza, account)))
if len(devices_list) == 0:
log.error(account + ' => Devicelistquery was NOT successful')
- self.publish_own_devices_list(account)
+ self.publish_own_devices_list(account, new=True)
return False
contact_jid = stanza.getAttr('from')
if contact_jid == my_jid:
@@ -1065,7 +1071,7 @@ class OmemoPlugin(GajimPlugin):
self.publish_own_devices_list(account)
else:
log.error(account + ' => Devicelistquery was NOT successful')
- self.publish_own_devices_list(account)
+ self.publish_own_devices_list(account, new=True)
@log_calls('OmemoPlugin')
def clear_device_list(self, account):