Additional modifications concerning to PubSub.

This commit is contained in:
Schimon Jehudah, Adv. 2024-11-19 17:40:33 +02:00
parent dac0c771dd
commit 412acc7cbe

View file

@ -970,7 +970,8 @@ class XmppClient(slixmpp.ClientXMPP):
.format(function_name, jid_full))
jid_bare = session['from'].bare
chat_type = await XmppUtilities.get_chat_type(self, jid_bare)
if XmppUtilities.is_access(self, jid, chat_type):
pubsubs = await XmppPubsub.get_pubsub_services(self)
if XmppUtilities.is_access(self, jid, chat_type) and pubsubs:
values = payload['values']
form = self['xep_0004'].make_form('form', 'Publish')
form['instructions'] = ('Choose a PubSub Jabber ID and verify '
@ -995,7 +996,6 @@ class XmppClient(slixmpp.ClientXMPP):
conferences = await XmppBookmark.get_bookmarks(self)
for conference in conferences:
jids.extend([conference['jid']])
pubsubs = await XmppPubsub.get_pubsub_services(self)
for pubsub in pubsubs:
jids.extend([pubsub['jid']])
for jid_bare in sorted(jids):
@ -1018,9 +1018,9 @@ class XmppClient(slixmpp.ClientXMPP):
ftype='list-single',
label='PubSub',
required=True,
value=self.boundjid.bare,
var='jid')
options.addOption(self.boundjid.bare, self.boundjid.bare)
for pubsub in pubsubs:
options.addOption(pubsub['jid'], pubsub['jid'])
iq = await self['xep_0030'].get_items(jid=self.boundjid.domain)
items = iq['disco_items']['items']
for item in items:
@ -1068,9 +1068,14 @@ class XmppClient(slixmpp.ClientXMPP):
elif chat_type == 'groupchat':
text_warn = ('This resource is restricted to moderators of {}.'
.format(jid_bare))
elif not pubsubs:
text_warn = 'No PubSub services were found on this server.'
else:
text_warn = 'This resource is restricted.'
session['has_next'] = False
session['next'] = None
session['notes'] = [['warn', text_warn]]
session['payload'] = None
return session
async def _handle_publish_db_preview(self, payload, session):
@ -1739,6 +1744,7 @@ class XmppClient(slixmpp.ClientXMPP):
# FIXME
# TODO Restore document export. Copy code from Slixprint.
async def _handle_recent_select(self, payload, session):
jid_full = session['from'].full
function_name = sys._getframe().f_code.co_name
@ -3145,14 +3151,12 @@ class XmppClient(slixmpp.ClientXMPP):
# jid_bare = self.boundjid.bare
# enabled_state = Config.get_setting_value(self, jid_bare, 'enabled')
results = await XmppPubsub.get_pubsub_services(self)
options = form.add_field(desc='Select a PubSub service.',
ftype='list-single',
label='Jabber ID',
value=self.boundjid.bare,
var='jid')
for result in results + [{'jid' : self.boundjid.bare,
'name' : self.alias}]:
for result in await XmppPubsub.get_pubsub_services(self):
name = result['name']
jid_bare = result['jid']
options.addOption(name, jid_bare)
@ -3171,8 +3175,7 @@ class XmppClient(slixmpp.ClientXMPP):
# enabled_state = Config.get_setting_value(self, jid_bare, 'enabled')
results = await XmppPubsub.get_pubsub_services(self)
for result in results + [{'jid' : self.boundjid.bare,
'name' : self.alias}]:
for result in await XmppPubsub.get_pubsub_services(self):
jid_bare = result['jid']
name = result['name']
enabled_state = Config.get_setting_value(