Fix handling of PubSub of own Jabber ID

This commit is contained in:
Schimon Jehudah 2024-05-13 07:28:12 +00:00
parent 57e0425c13
commit e4237f972f
5 changed files with 38 additions and 16 deletions

View file

@ -258,6 +258,19 @@ async def xmpp_pubsub_send_selected_entry(self, jid_bare, jid_file, node_id, ent
async def xmpp_pubsub_send_unread_items(self, jid_bare):
"""
Parameters
----------
jid_bare : TYPE
Bare Jabber ID.
Returns
-------
report : dict
URL and Number of processed entries.
"""
function_name = sys._getframe().f_code.co_name
logger.debug('{}: jid_bare: {}'.format(function_name, jid_bare))
jid_file = jid_bare.replace('/', '_')
@ -266,19 +279,23 @@ async def xmpp_pubsub_send_unread_items(self, jid_bare):
subscriptions = sqlite.get_active_feeds_url(db_file)
for url in subscriptions:
url = url[0]
# feed_id = sqlite.get_feed_id(db_file, url)
# feed_id = feed_id[0]
# feed_properties = sqlite.get_feed_properties(db_file, feed_id)
feed_id = sqlite.get_feed_id(db_file, url)
feed_id = feed_id[0]
# Publish to node 'urn:xmpp:microblog:0' for own JID
# Publish to node based on feed identifier for PubSub service.
if jid_bare == self.boundjid.bare:
node_id = 'urn:xmpp:microblog:0'
node_subtitle = None
node_title = None
else:
# feed_id = sqlite.get_feed_id(db_file, url)
# feed_id = feed_id[0]
# feed_properties = sqlite.get_feed_properties(db_file, feed_id)
# node_id = feed_properties[2]
# node_title = feed_properties[3]
# node_subtitle = feed_properties[5]
feed_id = sqlite.get_feed_id(db_file, url)
feed_id = feed_id[0]
node_id = sqlite.get_feed_identifier(db_file, feed_id)
node_id = node_id[0]
node_title = sqlite.get_feed_title(db_file, feed_id)
@ -290,8 +307,6 @@ async def xmpp_pubsub_send_unread_items(self, jid_bare):
self, jid_bare, node_id, xep, node_title, node_subtitle)
await XmppIQ.send(self, iq_create_node)
entries = sqlite.get_unread_entries_of_feed(db_file, feed_id)
print('xmpp_pubsub_send_unread_items',jid_bare)
print(node_id)
report[url] = len(entries)
for entry in entries:
feed_entry = pack_entry_into_dict(db_file, entry)

View file

@ -1634,8 +1634,8 @@ def get_unread_entries_of_feed(db_file, feed_id):
"""
)
par = (feed_id,)
count = cur.execute(sql, par).fetchall()
return count
result = cur.execute(sql, par).fetchall()
return result
def get_number_of_unread_entries_by_feed(db_file, feed_id):

View file

@ -1,2 +1,2 @@
__version__ = '0.1.61'
__version_info__ = (0, 1, 61)
__version__ = '0.1.62'
__version_info__ = (0, 1, 62)

View file

@ -305,8 +305,6 @@ class Slixfeed(slixmpp.ClientXMPP):
await self['xep_0115'].update_caps()
# self.send_presence()
await self.get_roster()
bookmarks = await XmppBookmark.get_bookmarks(self)
await action.xmpp_muc_autojoin(self, bookmarks)
results = await XmppPubsub.get_pubsub_services(self)
for result in results + [{'jid' : self.boundjid.bare,
'name' : self.alias}]:
@ -317,6 +315,10 @@ class Slixfeed(slixmpp.ClientXMPP):
await task.start_tasks_xmpp_pubsub(self, jid_bare)
# XmppCommand.adhoc_commands(self)
# self.service_reactions()
bookmarks = await XmppBookmark.get_bookmarks(self)
print('iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii')
await action.xmpp_muc_autojoin(self, bookmarks)
print('ooooooooooooooooooooooooooooooooo')
task.task_ping(self)
time_end = time.time()
difference = time_end - time_begin
@ -3124,7 +3126,7 @@ class Slixfeed(slixmpp.ClientXMPP):
form.add_field(var='jid',
ftype='hidden',
value=jid)
session['has_next'] = False
session['has_next'] = True
session['next'] = self._handle_nodes_action
session['allow_prev'] = True
session['payload'] = form

View file

@ -50,22 +50,27 @@ class XmppGroupchat:
await self.plugin['xep_0045'].join_muc_wait(jid,
alias,
presence_options = {"pfrom" : jid_from},
password=password)
password=password,
timeout=30)
result = 'joined ' + jid
except IqError as e:
logging.error('Error XmppIQ')
logging.error(str(e))
logging.error(jid)
result = 'error'
except IqTimeout as e:
logging.error('Timeout XmppIQ')
logging.error(str(e))
logging.error(jid)
result = 'timeout'
except PresenceError as e:
logging.error('Error Presence')
logging.error(str(e))
if (e.condition == 'forbidden' and
e.presence['error']['code'] == '403'):
logging.warning('{} is banned from {}'.format(self.alias, jid))
return 'ban'
result = 'ban'
return result
def leave(self, jid):