From 3597777bccf038bbe8ac0a2a9baa52077907dfa9 Mon Sep 17 00:00:00 2001 From: Schimon Jehudah Date: Mon, 13 May 2024 07:54:09 +0000 Subject: [PATCH] Restrict Ad-Hoc Publish to moderators (Thank you mirux). --- slixfeed/version.py | 4 ++-- slixfeed/xmpp/client.py | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/slixfeed/version.py b/slixfeed/version.py index 4b1da66..923b7b9 100644 --- a/slixfeed/version.py +++ b/slixfeed/version.py @@ -1,2 +1,2 @@ -__version__ = '0.1.62' -__version_info__ = (0, 1, 62) +__version__ = '0.1.63' +__version_info__ = (0, 1, 63) diff --git a/slixfeed/xmpp/client.py b/slixfeed/xmpp/client.py index ad5d640..22c2a5a 100644 --- a/slixfeed/xmpp/client.py +++ b/slixfeed/xmpp/client.py @@ -817,7 +817,11 @@ class Slixfeed(slixmpp.ClientXMPP): logger.debug('{}: jid_full: {}' .format(function_name, jid_full)) jid_bare = session['from'].bare - if is_operator(self, jid_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 is_operator(self, jid_bare) or moderator: form = self['xep_0004'].make_form('form', 'PubSub') form['instructions'] = 'Publish news items to PubSub nodes.' options = form.add_field(desc='From which medium source do you ' @@ -838,7 +842,11 @@ class Slixfeed(slixmpp.ClientXMPP): session['prev'] = None session['payload'] = form else: - text_warn = 'This resource is restricted to operators.' + if chat_type == 'groupchat': + text_warn = ('This resource is restricted to moderators of {}.' + .format(jid_bare)) + else: + text_warn = 'This resource is restricted to operators.' session['notes'] = [['warn', text_warn]] return session