From 70a62d3e3322c5ae5f3efa57961abfa71d14443a Mon Sep 17 00:00:00 2001 From: "Schimon Jehudah, Adv." Date: Thu, 12 Sep 2024 17:22:03 +0300 Subject: [PATCH] Fix moderator check upon chat messages (Thank you. roughnecks). --- slixfeed/xmpp/chat.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/slixfeed/xmpp/chat.py b/slixfeed/xmpp/chat.py index 7087ff4..18cbcaf 100644 --- a/slixfeed/xmpp/chat.py +++ b/slixfeed/xmpp/chat.py @@ -94,17 +94,15 @@ class XmppChat: # FIXME Code repetition. See below. # TODO Check alias by nickname associated with conference if message_type == 'groupchat': - if (message['muc']['nick'] == self.alias): + alias = message['muc']['nick'] + if (alias == self.alias): return - jid_full = message_from.full - if not XmppUtilities.is_moderator(self, jid_bare, jid_full): + if not XmppUtilities.is_moderator(self, jid_bare, alias): return - - if message_type == 'groupchat': # nick = message['from'][message['from'].index('/')+1:] # nick = str(message['from']) # nick = nick[nick.index('/')+1:] - if (message['muc']['nick'] == self.alias or + if (alias == self.alias or not message['body'].startswith('!')): return # token = await initdb( @@ -122,8 +120,7 @@ class XmppChat: # if nick not in operator: # return # approved = False - jid_full = message_from.full - if not XmppUtilities.is_moderator(self, jid_bare, jid_full): + if not XmppUtilities.is_moderator(self, jid_bare, alias): return # if role == 'moderator': # approved = True