[omemo] Only publish own deviceid if request fails
This commit is contained in:
@@ -764,19 +764,25 @@ class OmemoPlugin(GajimPlugin):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
@log_calls('OmemoPlugin')
|
@log_calls('OmemoPlugin')
|
||||||
def publish_own_devices_list(self, account):
|
def publish_own_devices_list(self, account, new=False):
|
||||||
""" Check if the passed event is a device list update and store the new
|
""" Get all currently known own active device ids and publish them
|
||||||
device ids.
|
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
account : str
|
account : str
|
||||||
the account name
|
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)
|
state = self.get_omemo_state(account)
|
||||||
devices_list = state.own_devices
|
if new:
|
||||||
devices_list.append(state.own_device_id)
|
devices_list = [state.own_device_id]
|
||||||
devices_list = list(set(devices_list))
|
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)
|
state.set_own_devices(devices_list)
|
||||||
|
|
||||||
log.debug(account + ' => Publishing own Devices: ' + str(
|
log.debug(account + ' => Publishing own Devices: ' + str(
|
||||||
@@ -1047,7 +1053,7 @@ class OmemoPlugin(GajimPlugin):
|
|||||||
devices_list = list(set(unpack_device_list_update(stanza, account)))
|
devices_list = list(set(unpack_device_list_update(stanza, account)))
|
||||||
if len(devices_list) == 0:
|
if len(devices_list) == 0:
|
||||||
log.error(account + ' => Devicelistquery was NOT successful')
|
log.error(account + ' => Devicelistquery was NOT successful')
|
||||||
self.publish_own_devices_list(account)
|
self.publish_own_devices_list(account, new=True)
|
||||||
return False
|
return False
|
||||||
contact_jid = stanza.getAttr('from')
|
contact_jid = stanza.getAttr('from')
|
||||||
if contact_jid == my_jid:
|
if contact_jid == my_jid:
|
||||||
@@ -1065,7 +1071,7 @@ class OmemoPlugin(GajimPlugin):
|
|||||||
self.publish_own_devices_list(account)
|
self.publish_own_devices_list(account)
|
||||||
else:
|
else:
|
||||||
log.error(account + ' => Devicelistquery was NOT successful')
|
log.error(account + ' => Devicelistquery was NOT successful')
|
||||||
self.publish_own_devices_list(account)
|
self.publish_own_devices_list(account, new=True)
|
||||||
|
|
||||||
@log_calls('OmemoPlugin')
|
@log_calls('OmemoPlugin')
|
||||||
def clear_device_list(self, account):
|
def clear_device_list(self, account):
|
||||||
|
|||||||
Reference in New Issue
Block a user