Fix handling of PubSub of own Jabber ID
This commit is contained in:
parent
57e0425c13
commit
e4237f972f
5 changed files with 38 additions and 16 deletions
|
@ -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):
|
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
|
function_name = sys._getframe().f_code.co_name
|
||||||
logger.debug('{}: jid_bare: {}'.format(function_name, jid_bare))
|
logger.debug('{}: jid_bare: {}'.format(function_name, jid_bare))
|
||||||
jid_file = jid_bare.replace('/', '_')
|
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)
|
subscriptions = sqlite.get_active_feeds_url(db_file)
|
||||||
for url in subscriptions:
|
for url in subscriptions:
|
||||||
url = url[0]
|
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:
|
if jid_bare == self.boundjid.bare:
|
||||||
node_id = 'urn:xmpp:microblog:0'
|
node_id = 'urn:xmpp:microblog:0'
|
||||||
node_subtitle = None
|
node_subtitle = None
|
||||||
node_title = None
|
node_title = None
|
||||||
else:
|
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_id = feed_properties[2]
|
||||||
# node_title = feed_properties[3]
|
# node_title = feed_properties[3]
|
||||||
# node_subtitle = feed_properties[5]
|
# 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 = sqlite.get_feed_identifier(db_file, feed_id)
|
||||||
node_id = node_id[0]
|
node_id = node_id[0]
|
||||||
node_title = sqlite.get_feed_title(db_file, feed_id)
|
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)
|
self, jid_bare, node_id, xep, node_title, node_subtitle)
|
||||||
await XmppIQ.send(self, iq_create_node)
|
await XmppIQ.send(self, iq_create_node)
|
||||||
entries = sqlite.get_unread_entries_of_feed(db_file, feed_id)
|
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)
|
report[url] = len(entries)
|
||||||
for entry in entries:
|
for entry in entries:
|
||||||
feed_entry = pack_entry_into_dict(db_file, entry)
|
feed_entry = pack_entry_into_dict(db_file, entry)
|
||||||
|
|
|
@ -1634,8 +1634,8 @@ def get_unread_entries_of_feed(db_file, feed_id):
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
par = (feed_id,)
|
par = (feed_id,)
|
||||||
count = cur.execute(sql, par).fetchall()
|
result = cur.execute(sql, par).fetchall()
|
||||||
return count
|
return result
|
||||||
|
|
||||||
|
|
||||||
def get_number_of_unread_entries_by_feed(db_file, feed_id):
|
def get_number_of_unread_entries_by_feed(db_file, feed_id):
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
__version__ = '0.1.61'
|
__version__ = '0.1.62'
|
||||||
__version_info__ = (0, 1, 61)
|
__version_info__ = (0, 1, 62)
|
||||||
|
|
|
@ -305,8 +305,6 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
await self['xep_0115'].update_caps()
|
await self['xep_0115'].update_caps()
|
||||||
# self.send_presence()
|
# self.send_presence()
|
||||||
await self.get_roster()
|
await self.get_roster()
|
||||||
bookmarks = await XmppBookmark.get_bookmarks(self)
|
|
||||||
await action.xmpp_muc_autojoin(self, bookmarks)
|
|
||||||
results = await XmppPubsub.get_pubsub_services(self)
|
results = await XmppPubsub.get_pubsub_services(self)
|
||||||
for result in results + [{'jid' : self.boundjid.bare,
|
for result in results + [{'jid' : self.boundjid.bare,
|
||||||
'name' : self.alias}]:
|
'name' : self.alias}]:
|
||||||
|
@ -317,6 +315,10 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
await task.start_tasks_xmpp_pubsub(self, jid_bare)
|
await task.start_tasks_xmpp_pubsub(self, jid_bare)
|
||||||
# XmppCommand.adhoc_commands(self)
|
# XmppCommand.adhoc_commands(self)
|
||||||
# self.service_reactions()
|
# self.service_reactions()
|
||||||
|
bookmarks = await XmppBookmark.get_bookmarks(self)
|
||||||
|
print('iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii')
|
||||||
|
await action.xmpp_muc_autojoin(self, bookmarks)
|
||||||
|
print('ooooooooooooooooooooooooooooooooo')
|
||||||
task.task_ping(self)
|
task.task_ping(self)
|
||||||
time_end = time.time()
|
time_end = time.time()
|
||||||
difference = time_end - time_begin
|
difference = time_end - time_begin
|
||||||
|
@ -3124,7 +3126,7 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
form.add_field(var='jid',
|
form.add_field(var='jid',
|
||||||
ftype='hidden',
|
ftype='hidden',
|
||||||
value=jid)
|
value=jid)
|
||||||
session['has_next'] = False
|
session['has_next'] = True
|
||||||
session['next'] = self._handle_nodes_action
|
session['next'] = self._handle_nodes_action
|
||||||
session['allow_prev'] = True
|
session['allow_prev'] = True
|
||||||
session['payload'] = form
|
session['payload'] = form
|
||||||
|
|
|
@ -50,22 +50,27 @@ class XmppGroupchat:
|
||||||
await self.plugin['xep_0045'].join_muc_wait(jid,
|
await self.plugin['xep_0045'].join_muc_wait(jid,
|
||||||
alias,
|
alias,
|
||||||
presence_options = {"pfrom" : jid_from},
|
presence_options = {"pfrom" : jid_from},
|
||||||
password=password)
|
password=password,
|
||||||
|
timeout=30)
|
||||||
|
result = 'joined ' + jid
|
||||||
except IqError as e:
|
except IqError as e:
|
||||||
logging.error('Error XmppIQ')
|
logging.error('Error XmppIQ')
|
||||||
logging.error(str(e))
|
logging.error(str(e))
|
||||||
logging.error(jid)
|
logging.error(jid)
|
||||||
|
result = 'error'
|
||||||
except IqTimeout as e:
|
except IqTimeout as e:
|
||||||
logging.error('Timeout XmppIQ')
|
logging.error('Timeout XmppIQ')
|
||||||
logging.error(str(e))
|
logging.error(str(e))
|
||||||
logging.error(jid)
|
logging.error(jid)
|
||||||
|
result = 'timeout'
|
||||||
except PresenceError as e:
|
except PresenceError as e:
|
||||||
logging.error('Error Presence')
|
logging.error('Error Presence')
|
||||||
logging.error(str(e))
|
logging.error(str(e))
|
||||||
if (e.condition == 'forbidden' and
|
if (e.condition == 'forbidden' and
|
||||||
e.presence['error']['code'] == '403'):
|
e.presence['error']['code'] == '403'):
|
||||||
logging.warning('{} is banned from {}'.format(self.alias, jid))
|
logging.warning('{} is banned from {}'.format(self.alias, jid))
|
||||||
return 'ban'
|
result = 'ban'
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
def leave(self, jid):
|
def leave(self, jid):
|
||||||
|
|
Loading…
Reference in a new issue