From 85311edcf21655b59df06a3b6ac7d7be771e3955 Mon Sep 17 00:00:00 2001 From: Schimon Jehudah Date: Wed, 13 Mar 2024 20:58:38 +0000 Subject: [PATCH] Fix error when checking for status moderator (Thank you roughnecks). Enhance Publish UI. --- slixfeed/version.py | 4 ++-- slixfeed/xmpp/client.py | 33 ++++++++++++++++++++++++++------- slixfeed/xmpp/component.py | 34 +++++++++++++++++++++++++++------- 3 files changed, 55 insertions(+), 16 deletions(-) diff --git a/slixfeed/version.py b/slixfeed/version.py index d0d929c..a8b95f8 100644 --- a/slixfeed/version.py +++ b/slixfeed/version.py @@ -1,2 +1,2 @@ -__version__ = '0.1.43' -__version_info__ = (0, 1, 43) +__version__ = '0.1.44' +__version_info__ = (0, 1, 44) diff --git a/slixfeed/xmpp/client.py b/slixfeed/xmpp/client.py index 20edea2..8e21036 100644 --- a/slixfeed/xmpp/client.py +++ b/slixfeed/xmpp/client.py @@ -721,23 +721,36 @@ class Slixfeed(slixmpp.ClientXMPP): async def _handle_publish(self, iq, session): form = self['xep_0004'].make_form('form', 'Publish') - form['instructions'] = ('In order to publish via Pubsub Social Feed ' - '(XEP-0472), you will have to choose a ' - 'Publish-Subscribe (XEP-0060) hostname and ' - 'be permitted to publish into it.') + form['instructions'] = ('In order to publish via PubSub, you will ' + 'have to choose a PubSub hostname and ' + 'have a privilege to publish into it.') # TODO Select from list-multi - form.add_field(var='subscription', + form.add_field(var='url', ftype='text-single', label='URL', desc='Enter subscription URL.', value='http://', required=True) - form.add_field(var='subscription', + form.add_field(var='pubsub', ftype='text-single', label='PubSub', desc='Enter a PubSub URL.', value='pubsub.' + self.boundjid.host, required=True) + form.add_field(var='node', + ftype='text-single', + label='Node', + desc='Node to publish at.', + required=False) + options = form.add_field(var='xep', + ftype='list-single', + label='Type', + desc='Select XEP.', + value='0060', + required=True) + options.addOption('XEP-0060: Publish-Subscribe', '0060') + options.addOption('XEP-0277: Microblogging over XMPP', '0277') + options.addOption('XEP-0472: Pubsub Social Feed', '0472') session['allow_prev'] = False session['has_next'] = True session['next'] = self._handle_preview @@ -750,7 +763,7 @@ class Slixfeed(slixmpp.ClientXMPP): function_name = sys._getframe().f_code.co_name logger.debug('{}: jid_full: {}' .format(function_name, jid_full)) - text_note = ('XEP-0472: Pubsub Social Feed will be available soon.') + text_note = ('PubSub support will be available soon.') session['notes'] = [['info', text_note]] session['payload'] = None return session @@ -867,6 +880,7 @@ class Slixfeed(slixmpp.ClientXMPP): .format(function_name, jid_full)) jid_bare = session['from'].bare chat_type = await get_chat_type(self, jid_bare) + moderator = None if chat_type == 'groupchat': moderator = is_moderator(self, jid_bare, jid_full) if chat_type == 'chat' or moderator: @@ -958,6 +972,7 @@ class Slixfeed(slixmpp.ClientXMPP): .format(function_name, jid_full)) jid_bare = session['from'].bare chat_type = await get_chat_type(self, jid_bare) + moderator = None if chat_type == 'groupchat': moderator = is_moderator(self, jid_bare, jid_full) if chat_type == 'chat' or moderator: @@ -1558,6 +1573,7 @@ class Slixfeed(slixmpp.ClientXMPP): .format(function_name, jid_full)) jid_bare = session['from'].bare chat_type = await get_chat_type(self, jid_bare) + moderator = None if chat_type == 'groupchat': moderator = is_moderator(self, jid_bare, jid_full) if chat_type == 'chat' or moderator: @@ -1979,6 +1995,7 @@ class Slixfeed(slixmpp.ClientXMPP): .format(function_name, jid_full)) jid_bare = session['from'].bare chat_type = await get_chat_type(self, jid_bare) + moderator = None if chat_type == 'groupchat': moderator = is_moderator(self, jid_bare, jid_full) if chat_type == 'chat' or moderator: @@ -2330,6 +2347,7 @@ class Slixfeed(slixmpp.ClientXMPP): jid_bare = session['from'].bare jid_full = str(session['from']) chat_type = await get_chat_type(self, jid_bare) + moderator = None if chat_type == 'groupchat': moderator = is_moderator(self, jid_bare, jid_full) if chat_type == 'chat' or moderator: @@ -2719,6 +2737,7 @@ class Slixfeed(slixmpp.ClientXMPP): .format(function_name, jid_full)) jid_bare = session['from'].bare chat_type = await get_chat_type(self, jid_bare) + moderator = None if chat_type == 'groupchat': moderator = is_moderator(self, jid_bare, jid_full) if chat_type == 'chat' or moderator: diff --git a/slixfeed/xmpp/component.py b/slixfeed/xmpp/component.py index 19ca3d3..e1fb2f3 100644 --- a/slixfeed/xmpp/component.py +++ b/slixfeed/xmpp/component.py @@ -681,23 +681,36 @@ class SlixfeedComponent(slixmpp.ComponentXMPP): async def _handle_publish(self, iq, session): form = self['xep_0004'].make_form('form', 'Publish') - form['instructions'] = ('In order to publish via Pubsub Social Feed ' - '(XEP-0472), you will have to choose a ' - 'Publish-Subscribe (XEP-0060) hostname and ' - 'be permitted to publish into it.') + form['instructions'] = ('In order to publish via PubSub, you will ' + 'have to choose a PubSub hostname and ' + 'have a privilege to publish into it.') # TODO Select from list-multi - form.add_field(var='subscription', + form.add_field(var='url', ftype='text-single', label='URL', desc='Enter subscription URL.', value='http://', required=True) - form.add_field(var='subscription', + form.add_field(var='pubsub', ftype='text-single', label='PubSub', desc='Enter a PubSub URL.', value='pubsub.' + self.boundjid.host, required=True) + form.add_field(var='node', + ftype='text-single', + label='Node', + desc='Node to publish at.', + required=False) + options = form.add_field(var='xep', + ftype='list-single', + label='Type', + desc='Select XEP.', + value='0060', + required=True) + options.addOption('XEP-0060: Publish-Subscribe', '0060') + options.addOption('XEP-0277: Microblogging over XMPP', '0277') + options.addOption('XEP-0472: Pubsub Social Feed', '0472') session['allow_prev'] = False session['has_next'] = True session['next'] = self._handle_preview @@ -710,7 +723,7 @@ class SlixfeedComponent(slixmpp.ComponentXMPP): function_name = sys._getframe().f_code.co_name logger.debug('{}: jid_full: {}' .format(function_name, jid_full)) - text_note = ('XEP-0472: Pubsub Social Feed will be available soon.') + text_note = ('PubSub support will be available soon.') session['notes'] = [['info', text_note]] session['payload'] = None return session @@ -827,6 +840,7 @@ class SlixfeedComponent(slixmpp.ComponentXMPP): .format(function_name, jid_full)) jid_bare = session['from'].bare chat_type = await get_chat_type(self, jid_bare) + moderator = None if chat_type == 'groupchat': moderator = is_moderator(self, jid_bare, jid_full) if chat_type == 'chat' or moderator: @@ -918,6 +932,7 @@ class SlixfeedComponent(slixmpp.ComponentXMPP): .format(function_name, jid_full)) jid_bare = session['from'].bare chat_type = await get_chat_type(self, jid_bare) + moderator = None if chat_type == 'groupchat': moderator = is_moderator(self, jid_bare, jid_full) if chat_type == 'chat' or moderator: @@ -1518,6 +1533,7 @@ class SlixfeedComponent(slixmpp.ComponentXMPP): .format(function_name, jid_full)) jid_bare = session['from'].bare chat_type = await get_chat_type(self, jid_bare) + moderator = None if chat_type == 'groupchat': moderator = is_moderator(self, jid_bare, jid_full) if chat_type == 'chat' or moderator: @@ -1939,6 +1955,7 @@ class SlixfeedComponent(slixmpp.ComponentXMPP): .format(function_name, jid_full)) jid_bare = session['from'].bare chat_type = await get_chat_type(self, jid_bare) + moderator = None if chat_type == 'groupchat': moderator = is_moderator(self, jid_bare, jid_full) if chat_type == 'chat' or moderator: @@ -2290,6 +2307,8 @@ class SlixfeedComponent(slixmpp.ComponentXMPP): jid_bare = session['from'].bare jid_full = str(session['from']) chat_type = await get_chat_type(self, jid_bare) + moderator = None + moderator = None if chat_type == 'groupchat': moderator = is_moderator(self, jid_bare, jid_full) if chat_type == 'chat' or moderator: @@ -2679,6 +2698,7 @@ class SlixfeedComponent(slixmpp.ComponentXMPP): .format(function_name, jid_full)) jid_bare = session['from'].bare chat_type = await get_chat_type(self, jid_bare) + moderator = None if chat_type == 'groupchat': moderator = is_moderator(self, jid_bare, jid_full) if chat_type == 'chat' or moderator: