Fix error when checking for status moderator (Thank you roughnecks).
Enhance Publish UI.
This commit is contained in:
parent
f18659fd88
commit
85311edcf2
3 changed files with 55 additions and 16 deletions
|
@ -1,2 +1,2 @@
|
||||||
__version__ = '0.1.43'
|
__version__ = '0.1.44'
|
||||||
__version_info__ = (0, 1, 43)
|
__version_info__ = (0, 1, 44)
|
||||||
|
|
|
@ -721,23 +721,36 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
|
|
||||||
async def _handle_publish(self, iq, session):
|
async def _handle_publish(self, iq, session):
|
||||||
form = self['xep_0004'].make_form('form', 'Publish')
|
form = self['xep_0004'].make_form('form', 'Publish')
|
||||||
form['instructions'] = ('In order to publish via Pubsub Social Feed '
|
form['instructions'] = ('In order to publish via PubSub, you will '
|
||||||
'(XEP-0472), you will have to choose a '
|
'have to choose a PubSub hostname and '
|
||||||
'Publish-Subscribe (XEP-0060) hostname and '
|
'have a privilege to publish into it.')
|
||||||
'be permitted to publish into it.')
|
|
||||||
# TODO Select from list-multi
|
# TODO Select from list-multi
|
||||||
form.add_field(var='subscription',
|
form.add_field(var='url',
|
||||||
ftype='text-single',
|
ftype='text-single',
|
||||||
label='URL',
|
label='URL',
|
||||||
desc='Enter subscription URL.',
|
desc='Enter subscription URL.',
|
||||||
value='http://',
|
value='http://',
|
||||||
required=True)
|
required=True)
|
||||||
form.add_field(var='subscription',
|
form.add_field(var='pubsub',
|
||||||
ftype='text-single',
|
ftype='text-single',
|
||||||
label='PubSub',
|
label='PubSub',
|
||||||
desc='Enter a PubSub URL.',
|
desc='Enter a PubSub URL.',
|
||||||
value='pubsub.' + self.boundjid.host,
|
value='pubsub.' + self.boundjid.host,
|
||||||
required=True)
|
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['allow_prev'] = False
|
||||||
session['has_next'] = True
|
session['has_next'] = True
|
||||||
session['next'] = self._handle_preview
|
session['next'] = self._handle_preview
|
||||||
|
@ -750,7 +763,7 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
function_name = sys._getframe().f_code.co_name
|
function_name = sys._getframe().f_code.co_name
|
||||||
logger.debug('{}: jid_full: {}'
|
logger.debug('{}: jid_full: {}'
|
||||||
.format(function_name, 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['notes'] = [['info', text_note]]
|
||||||
session['payload'] = None
|
session['payload'] = None
|
||||||
return session
|
return session
|
||||||
|
@ -867,6 +880,7 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
.format(function_name, jid_full))
|
.format(function_name, jid_full))
|
||||||
jid_bare = session['from'].bare
|
jid_bare = session['from'].bare
|
||||||
chat_type = await get_chat_type(self, jid_bare)
|
chat_type = await get_chat_type(self, jid_bare)
|
||||||
|
moderator = None
|
||||||
if chat_type == 'groupchat':
|
if chat_type == 'groupchat':
|
||||||
moderator = is_moderator(self, jid_bare, jid_full)
|
moderator = is_moderator(self, jid_bare, jid_full)
|
||||||
if chat_type == 'chat' or moderator:
|
if chat_type == 'chat' or moderator:
|
||||||
|
@ -958,6 +972,7 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
.format(function_name, jid_full))
|
.format(function_name, jid_full))
|
||||||
jid_bare = session['from'].bare
|
jid_bare = session['from'].bare
|
||||||
chat_type = await get_chat_type(self, jid_bare)
|
chat_type = await get_chat_type(self, jid_bare)
|
||||||
|
moderator = None
|
||||||
if chat_type == 'groupchat':
|
if chat_type == 'groupchat':
|
||||||
moderator = is_moderator(self, jid_bare, jid_full)
|
moderator = is_moderator(self, jid_bare, jid_full)
|
||||||
if chat_type == 'chat' or moderator:
|
if chat_type == 'chat' or moderator:
|
||||||
|
@ -1558,6 +1573,7 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
.format(function_name, jid_full))
|
.format(function_name, jid_full))
|
||||||
jid_bare = session['from'].bare
|
jid_bare = session['from'].bare
|
||||||
chat_type = await get_chat_type(self, jid_bare)
|
chat_type = await get_chat_type(self, jid_bare)
|
||||||
|
moderator = None
|
||||||
if chat_type == 'groupchat':
|
if chat_type == 'groupchat':
|
||||||
moderator = is_moderator(self, jid_bare, jid_full)
|
moderator = is_moderator(self, jid_bare, jid_full)
|
||||||
if chat_type == 'chat' or moderator:
|
if chat_type == 'chat' or moderator:
|
||||||
|
@ -1979,6 +1995,7 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
.format(function_name, jid_full))
|
.format(function_name, jid_full))
|
||||||
jid_bare = session['from'].bare
|
jid_bare = session['from'].bare
|
||||||
chat_type = await get_chat_type(self, jid_bare)
|
chat_type = await get_chat_type(self, jid_bare)
|
||||||
|
moderator = None
|
||||||
if chat_type == 'groupchat':
|
if chat_type == 'groupchat':
|
||||||
moderator = is_moderator(self, jid_bare, jid_full)
|
moderator = is_moderator(self, jid_bare, jid_full)
|
||||||
if chat_type == 'chat' or moderator:
|
if chat_type == 'chat' or moderator:
|
||||||
|
@ -2330,6 +2347,7 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
jid_bare = session['from'].bare
|
jid_bare = session['from'].bare
|
||||||
jid_full = str(session['from'])
|
jid_full = str(session['from'])
|
||||||
chat_type = await get_chat_type(self, jid_bare)
|
chat_type = await get_chat_type(self, jid_bare)
|
||||||
|
moderator = None
|
||||||
if chat_type == 'groupchat':
|
if chat_type == 'groupchat':
|
||||||
moderator = is_moderator(self, jid_bare, jid_full)
|
moderator = is_moderator(self, jid_bare, jid_full)
|
||||||
if chat_type == 'chat' or moderator:
|
if chat_type == 'chat' or moderator:
|
||||||
|
@ -2719,6 +2737,7 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
.format(function_name, jid_full))
|
.format(function_name, jid_full))
|
||||||
jid_bare = session['from'].bare
|
jid_bare = session['from'].bare
|
||||||
chat_type = await get_chat_type(self, jid_bare)
|
chat_type = await get_chat_type(self, jid_bare)
|
||||||
|
moderator = None
|
||||||
if chat_type == 'groupchat':
|
if chat_type == 'groupchat':
|
||||||
moderator = is_moderator(self, jid_bare, jid_full)
|
moderator = is_moderator(self, jid_bare, jid_full)
|
||||||
if chat_type == 'chat' or moderator:
|
if chat_type == 'chat' or moderator:
|
||||||
|
|
|
@ -681,23 +681,36 @@ class SlixfeedComponent(slixmpp.ComponentXMPP):
|
||||||
|
|
||||||
async def _handle_publish(self, iq, session):
|
async def _handle_publish(self, iq, session):
|
||||||
form = self['xep_0004'].make_form('form', 'Publish')
|
form = self['xep_0004'].make_form('form', 'Publish')
|
||||||
form['instructions'] = ('In order to publish via Pubsub Social Feed '
|
form['instructions'] = ('In order to publish via PubSub, you will '
|
||||||
'(XEP-0472), you will have to choose a '
|
'have to choose a PubSub hostname and '
|
||||||
'Publish-Subscribe (XEP-0060) hostname and '
|
'have a privilege to publish into it.')
|
||||||
'be permitted to publish into it.')
|
|
||||||
# TODO Select from list-multi
|
# TODO Select from list-multi
|
||||||
form.add_field(var='subscription',
|
form.add_field(var='url',
|
||||||
ftype='text-single',
|
ftype='text-single',
|
||||||
label='URL',
|
label='URL',
|
||||||
desc='Enter subscription URL.',
|
desc='Enter subscription URL.',
|
||||||
value='http://',
|
value='http://',
|
||||||
required=True)
|
required=True)
|
||||||
form.add_field(var='subscription',
|
form.add_field(var='pubsub',
|
||||||
ftype='text-single',
|
ftype='text-single',
|
||||||
label='PubSub',
|
label='PubSub',
|
||||||
desc='Enter a PubSub URL.',
|
desc='Enter a PubSub URL.',
|
||||||
value='pubsub.' + self.boundjid.host,
|
value='pubsub.' + self.boundjid.host,
|
||||||
required=True)
|
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['allow_prev'] = False
|
||||||
session['has_next'] = True
|
session['has_next'] = True
|
||||||
session['next'] = self._handle_preview
|
session['next'] = self._handle_preview
|
||||||
|
@ -710,7 +723,7 @@ class SlixfeedComponent(slixmpp.ComponentXMPP):
|
||||||
function_name = sys._getframe().f_code.co_name
|
function_name = sys._getframe().f_code.co_name
|
||||||
logger.debug('{}: jid_full: {}'
|
logger.debug('{}: jid_full: {}'
|
||||||
.format(function_name, 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['notes'] = [['info', text_note]]
|
||||||
session['payload'] = None
|
session['payload'] = None
|
||||||
return session
|
return session
|
||||||
|
@ -827,6 +840,7 @@ class SlixfeedComponent(slixmpp.ComponentXMPP):
|
||||||
.format(function_name, jid_full))
|
.format(function_name, jid_full))
|
||||||
jid_bare = session['from'].bare
|
jid_bare = session['from'].bare
|
||||||
chat_type = await get_chat_type(self, jid_bare)
|
chat_type = await get_chat_type(self, jid_bare)
|
||||||
|
moderator = None
|
||||||
if chat_type == 'groupchat':
|
if chat_type == 'groupchat':
|
||||||
moderator = is_moderator(self, jid_bare, jid_full)
|
moderator = is_moderator(self, jid_bare, jid_full)
|
||||||
if chat_type == 'chat' or moderator:
|
if chat_type == 'chat' or moderator:
|
||||||
|
@ -918,6 +932,7 @@ class SlixfeedComponent(slixmpp.ComponentXMPP):
|
||||||
.format(function_name, jid_full))
|
.format(function_name, jid_full))
|
||||||
jid_bare = session['from'].bare
|
jid_bare = session['from'].bare
|
||||||
chat_type = await get_chat_type(self, jid_bare)
|
chat_type = await get_chat_type(self, jid_bare)
|
||||||
|
moderator = None
|
||||||
if chat_type == 'groupchat':
|
if chat_type == 'groupchat':
|
||||||
moderator = is_moderator(self, jid_bare, jid_full)
|
moderator = is_moderator(self, jid_bare, jid_full)
|
||||||
if chat_type == 'chat' or moderator:
|
if chat_type == 'chat' or moderator:
|
||||||
|
@ -1518,6 +1533,7 @@ class SlixfeedComponent(slixmpp.ComponentXMPP):
|
||||||
.format(function_name, jid_full))
|
.format(function_name, jid_full))
|
||||||
jid_bare = session['from'].bare
|
jid_bare = session['from'].bare
|
||||||
chat_type = await get_chat_type(self, jid_bare)
|
chat_type = await get_chat_type(self, jid_bare)
|
||||||
|
moderator = None
|
||||||
if chat_type == 'groupchat':
|
if chat_type == 'groupchat':
|
||||||
moderator = is_moderator(self, jid_bare, jid_full)
|
moderator = is_moderator(self, jid_bare, jid_full)
|
||||||
if chat_type == 'chat' or moderator:
|
if chat_type == 'chat' or moderator:
|
||||||
|
@ -1939,6 +1955,7 @@ class SlixfeedComponent(slixmpp.ComponentXMPP):
|
||||||
.format(function_name, jid_full))
|
.format(function_name, jid_full))
|
||||||
jid_bare = session['from'].bare
|
jid_bare = session['from'].bare
|
||||||
chat_type = await get_chat_type(self, jid_bare)
|
chat_type = await get_chat_type(self, jid_bare)
|
||||||
|
moderator = None
|
||||||
if chat_type == 'groupchat':
|
if chat_type == 'groupchat':
|
||||||
moderator = is_moderator(self, jid_bare, jid_full)
|
moderator = is_moderator(self, jid_bare, jid_full)
|
||||||
if chat_type == 'chat' or moderator:
|
if chat_type == 'chat' or moderator:
|
||||||
|
@ -2290,6 +2307,8 @@ class SlixfeedComponent(slixmpp.ComponentXMPP):
|
||||||
jid_bare = session['from'].bare
|
jid_bare = session['from'].bare
|
||||||
jid_full = str(session['from'])
|
jid_full = str(session['from'])
|
||||||
chat_type = await get_chat_type(self, jid_bare)
|
chat_type = await get_chat_type(self, jid_bare)
|
||||||
|
moderator = None
|
||||||
|
moderator = None
|
||||||
if chat_type == 'groupchat':
|
if chat_type == 'groupchat':
|
||||||
moderator = is_moderator(self, jid_bare, jid_full)
|
moderator = is_moderator(self, jid_bare, jid_full)
|
||||||
if chat_type == 'chat' or moderator:
|
if chat_type == 'chat' or moderator:
|
||||||
|
@ -2679,6 +2698,7 @@ class SlixfeedComponent(slixmpp.ComponentXMPP):
|
||||||
.format(function_name, jid_full))
|
.format(function_name, jid_full))
|
||||||
jid_bare = session['from'].bare
|
jid_bare = session['from'].bare
|
||||||
chat_type = await get_chat_type(self, jid_bare)
|
chat_type = await get_chat_type(self, jid_bare)
|
||||||
|
moderator = None
|
||||||
if chat_type == 'groupchat':
|
if chat_type == 'groupchat':
|
||||||
moderator = is_moderator(self, jid_bare, jid_full)
|
moderator = is_moderator(self, jid_bare, jid_full)
|
||||||
if chat_type == 'chat' or moderator:
|
if chat_type == 'chat' or moderator:
|
||||||
|
|
Loading…
Reference in a new issue