Python : Fix error KeyError: 'urn:xmpp:microblog:0'.

This commit is contained in:
Schimon Jehudah, Adv. 2024-10-15 22:14:19 +03:00
parent cc1061ecf1
commit 129e80e8ba

16
fasi.py
View file

@ -509,12 +509,21 @@ class HttpInstance:
# Set node name to 'urn:xmpp:microblog:0' # Set node name to 'urn:xmpp:microblog:0'
jid_kind = jid_details['kind'] jid_kind = jid_details['kind']
if jid_kind not in ('conference', 'mix', 'muc') and '@' in jid_bare and not node_name: nodes = jid_details['nodes']
if (jid_kind not in ('conference', 'mix', 'muc') and
'@' in jid_bare and
not node_name and
'urn:xmpp:microblog:0' in nodes):
node_name = 'urn:xmpp:microblog:0' node_name = 'urn:xmpp:microblog:0'
if ('@' in jid_bare and
'urn:xmpp:microblog:0' not in nodes and
jid_kind not in ('conference', 'mix', 'muc')):
count = 0
else:
count = nodes[node_name]['count'] if node_name in nodes else jid_details['count']
action = jid_details['action'] action = jid_details['action']
nodes = jid_details['nodes']
count = nodes[node_name]['count'] if node_name else jid_details['count']
instance = jid_details['instance'] instance = jid_details['instance']
items = jid_details['items'] items = jid_details['items']
jid_info = { jid_info = {
@ -992,6 +1001,7 @@ class Syndication:
if (not isinstance(title, ET.Element) and if (not isinstance(title, ET.Element) and
not isinstance(links, ET.Element)): return None not isinstance(links, ET.Element)): return None
title_text = '' if title == None else title.text title_text = '' if title == None else title.text
link_href = ''
if isinstance(links, ET.Element): if isinstance(links, ET.Element):
for link in item_payload.findall(namespace + 'link'): for link in item_payload.findall(namespace + 'link'):
link_href = link.attrib['href'] if 'href' in link.attrib else '' link_href = link.attrib['href'] if 'href' in link.attrib else ''