Fix XEP-0128

Broken since 125336aeee due to unforeseen consequences of a variable
removal.
This commit is contained in:
mathieui 2016-10-04 19:26:03 +02:00
parent d4bff8dee6
commit e691850a2b

View file

@ -38,9 +38,8 @@ class StaticExtendedDisco(object):
The data parameter may provide:
data -- Either a single data form, or a list of data forms.
"""
with self.static.lock:
self.del_extended_info(jid, node, ifrom, data)
self.add_extended_info(jid, node, ifrom, data)
self.del_extended_info(jid, node, ifrom, data)
self.add_extended_info(jid, node, ifrom, data)
def add_extended_info(self, jid, node, ifrom, data):
"""
@ -49,16 +48,15 @@ class StaticExtendedDisco(object):
The data parameter may provide:
data -- Either a single data form, or a list of data forms.
"""
with self.static.lock:
self.static.add_node(jid, node)
self.static.add_node(jid, node)
forms = data.get('data', [])
if not isinstance(forms, list):
forms = [forms]
forms = data.get('data', [])
if not isinstance(forms, list):
forms = [forms]
info = self.static.get_node(jid, node)['info']
for form in forms:
info.append(form)
info = self.static.get_node(jid, node)['info']
for form in forms:
info.append(form)
def del_extended_info(self, jid, node, ifrom, data):
"""
@ -66,8 +64,7 @@ class StaticExtendedDisco(object):
The data parameter is not used.
"""
with self.static.lock:
if self.static.node_exists(jid, node):
info = self.static.get_node(jid, node)['info']
for form in info['substanza']:
info.xml.remove(form.xml)
if self.static.node_exists(jid, node):
info = self.static.get_node(jid, node)['info']
for form in info['substanza']:
info.xml.remove(form.xml)