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