Python : Fix an error upon failiure to achieve items of a Jabber ID (Thanks. ThUnD3r|Gr33n)

This commit is contained in:
Schimon Jehudah, Adv. 2024-10-15 20:37:46 +03:00
parent 899f87865d
commit cc1061ecf1

39
fasi.py
View file

@ -628,7 +628,7 @@ class FileUtilities:
async def cache_jid_data(jabber_id, password, jid_bare, node_name=None, item_id=None, alias=None): async def cache_jid_data(jabber_id, password, jid_bare, node_name=None, item_id=None, alias=None):
count = title = '' count = iq_disco_items_list = iq_disco_items_items_list = title = ''
jid_vcard = { jid_vcard = {
'name' : '', 'name' : '',
'note' : '', 'note' : '',
@ -675,23 +675,24 @@ class FileUtilities:
# TODO /d/pubsub.nicoco.fr/blog/urn-uuid-53e43061-1962-3112-bb8a-1473dca61719 # TODO /d/pubsub.nicoco.fr/blog/urn-uuid-53e43061-1962-3112-bb8a-1473dca61719
jid_items = await XmppXep0030.get_jid_items(xmpp_instance, jid_bare) jid_items = await XmppXep0030.get_jid_items(xmpp_instance, jid_bare)
iq = jid_items['iq'] if isinstance(jid_items['iq'], stanza.iq.Iq):
iq_disco_items = iq['disco_items'] iq = jid_items['iq']
iq_disco_items_items = iq_disco_items['items'] iq_disco_items = iq['disco_items']
#iq_disco_items_set = {''} iq_disco_items_items = iq_disco_items['items']
iq_disco_items_list = [] #iq_disco_items_set = {''}
iq_disco_items_items_list = [] iq_disco_items_list = []
for item in iq_disco_items_items: iq_disco_items_items_list = []
if jid_kind == 'muc': for item in iq_disco_items_items:
#iq_disco_items_set.update([item[2]]) if jid_kind == 'muc':
iq_disco_items_list.append(item[2]) #iq_disco_items_set.update([item[2]])
else: iq_disco_items_list.append(item[2])
#iq_disco_items_set.update([item[1]]) else:
iq_disco_items_list.append(item[1]) #iq_disco_items_set.update([item[1]])
iq_disco_items_items_list.append( iq_disco_items_list.append(item[1])
[item[0] or '', item[1] or '', item[2] or '']) iq_disco_items_items_list.append(
#count = len(iq_disco_items_set) [item[0] or '', item[1] or '', item[2] or ''])
count = len(iq_disco_items_list) #count = len(iq_disco_items_set)
count = len(iq_disco_items_list)
# Title # Title
print('Title') print('Title')
@ -774,7 +775,7 @@ class FileUtilities:
print('Node items') print('Node items')
nodes = {} nodes = {}
#if node_name and node_name in iq_disco_items_set: #if node_name and node_name in iq_disco_items_set:
if node_name and node_name in iq_disco_items_list: if iq_disco_items_list and node_name and node_name in iq_disco_items_list:
action = 'Browse' action = 'Browse'
node_item_ids = await XmppXep0060.get_node_item_ids(xmpp_instance, jid_bare, node_name) node_item_ids = await XmppXep0060.get_node_item_ids(xmpp_instance, jid_bare, node_name)
if isinstance(node_item_ids['iq'], stanza.iq.Iq): if isinstance(node_item_ids['iq'], stanza.iq.Iq):