From 721e26a38e0beef386700c4746aaab8d91788843 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 17 Dec 2020 09:59:28 +0000 Subject: [PATCH] Extra checks on moderator status This is to prevent moderator wars --- daemon.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/daemon.py b/daemon.py index e4818d0df..23d4fe7cf 100644 --- a/daemon.py +++ b/daemon.py @@ -1766,23 +1766,27 @@ class PubServer(BaseHTTPRequestHandler): # person options screen, permission to post to newswire # See htmlPersonOptions if '&submitPostToNews=' in optionsConfirmParams: - if isModerator(self.server.baseDir, chooserNickname): + adminNickname = getConfigParam(self.server.baseDir, 'admin') + if (chooserNickname == adminNickname or + (isModerator(self.server.baseDir, chooserNickname) and + not isModerator(self.server.baseDir, optionsNickname))): postsToNews = None if 'postsToNews=' in optionsConfirmParams: postsToNews = optionsConfirmParams.split('postsToNews=')[1] if '&' in postsToNews: postsToNews = postsToNews.split('&')[0] - newswireBlockedFilename = \ - self.server.baseDir + '/accounts/' + \ - optionsNickname + '@' + optionsDomain + '/.nonewswire' + accountDir = self.server.baseDir + '/accounts/' + \ + optionsNickname + '@' + optionsDomain + newswireBlockedFilename = accountDir + '/.nonewswire' if postsToNews == 'on': if os.path.isfile(newswireBlockedFilename): os.remove(newswireBlockedFilename) else: - noNewswireFile = open(newswireBlockedFilename, "w+") - if noNewswireFile: - noNewswireFile.write('\n') - noNewswireFile.close() + if os.path.isdir(accountDir): + noNewswireFile = open(newswireBlockedFilename, "w+") + if noNewswireFile: + noNewswireFile.write('\n') + noNewswireFile.close() self._redirect_headers(usersPath + '/' + self.server.defaultTimeline + '?page='+str(pageNumber), cookie,