Improve access restriction (Thank you mirux)

This commit is contained in:
Schimon Jehudah 2024-05-13 13:08:57 +00:00
parent d6cd09d746
commit 095980de47

View file

@ -818,23 +818,18 @@ 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 access = None
operator = None print('PERMISSION JID : ' + jid_full)
print('JID {} CHAT {}'.format(jid_full, chat_type)) print('PERMISSION CHAT : ' + chat_type)
print('JID {} CHAT {}'.format(jid_full, chat_type)) if is_operator(self, jid_bare):
print('JID {} CHAT {}'.format(jid_full, chat_type))
print('JID {} CHAT {}'.format(jid_full, chat_type))
print('JID {} CHAT {}'.format(jid_full, chat_type))
if chat_type == 'groupchat': if chat_type == 'groupchat':
moderator = is_moderator(self, jid_bare, jid_full) if is_moderator(self, jid_bare, jid_full):
access = True
print('PERMISSION MOD')
else: else:
operator = is_operator(self, jid_bare) access = True
print('OPERATOR {} MODERATOR {}'.format(operator, moderator)) print('PERMISSION OP')
print('OPERATOR {} MODERATOR {}'.format(operator, moderator)) if access:
print('OPERATOR {} MODERATOR {}'.format(operator, moderator))
print('OPERATOR {} MODERATOR {}'.format(operator, moderator))
print('OPERATOR {} MODERATOR {}'.format(operator, moderator))
if operator or moderator:
form = self['xep_0004'].make_form('form', 'PubSub') form = self['xep_0004'].make_form('form', 'PubSub')
form['instructions'] = 'Publish news items to PubSub nodes.' form['instructions'] = 'Publish news items to PubSub nodes.'
options = form.add_field(desc='From which medium source do you ' options = form.add_field(desc='From which medium source do you '
@ -847,7 +842,7 @@ class Slixfeed(slixmpp.ClientXMPP):
options.addOption('URL', 'url') options.addOption('URL', 'url')
form.add_field(ftype='fixed', form.add_field(ftype='fixed',
label='* Attention', label='* Attention',
desc='Results are viewed best in Movim and ' desc='Results are viewed best with Movim and '
'Libervia.') 'Libervia.')
session['allow_prev'] = False session['allow_prev'] = False
session['has_next'] = True session['has_next'] = True