From b13be2f5b49cb519ecc37a9cd21f896ad3216467 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 9 Dec 2020 23:30:15 +0000 Subject: [PATCH] Default moderation action --- daemon.py | 25 ++++++++++++++++++------- webapp_moderation.py | 4 ++-- webapp_timeline.py | 34 ++++++++++++++++++++-------------- 3 files changed, 40 insertions(+), 23 deletions(-) diff --git a/daemon.py b/daemon.py index 55174b46f..a9fdcbd7b 100644 --- a/daemon.py +++ b/daemon.py @@ -8131,6 +8131,9 @@ class PubServer(BaseHTTPRequestHandler): self.server.votingTimeMins) fullWidthTimelineButtonHeader = \ self.server.fullWidthTimelineButtonHeader + if '?' in nickname: + moderationActionStr = nickname.split('?')[1] + nickname = nickname.split('?')[0] msg = \ htmlModeration(self.server.cssCache, self.server.defaultTimeline, @@ -8158,7 +8161,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.iconsAsButtons, self.server.rssIconAtTop, self.server.publishButtonAtTop, - authorized) + authorized, moderationActionStr) msg = msg.encode('utf-8') self._set_headers('text/html', len(msg), cookie, callingDomain) @@ -8181,6 +8184,8 @@ class PubServer(BaseHTTPRequestHandler): if debug: nickname = path.replace('/users/', '') nickname = nickname.replace('/moderation', '') + if '?' in nickname: + nickname = nickname.split('?')[0] print('DEBUG: ' + nickname + ' was not authorized to access ' + path) if debug: @@ -11006,11 +11011,14 @@ class PubServer(BaseHTTPRequestHandler): return blockDomain = self.path.split('/accountinfo?blockdomain=')[1] blockDomain = urllib.parse.unquote_plus(blockDomain.strip()) + searchHandle = '' + if '?' in blockDomain: + searchHandle = '?' + blockDomain.split('?')[1] + blockDomain = blockDomain.split('?')[0] addGlobalBlock(self.server.baseDir, nickname, blockDomain) self.server.GETbusy = False - # TODO this should go back to the account info screen - self._redirect_headers('/users/' + nickname + '/moderation', - cookie, callingDomain) + self._redirect_headers('/users/' + nickname + '/moderation' + + searchHandle, cookie, callingDomain) return # unblock a domain from htmlAccountInfo @@ -11024,11 +11032,14 @@ class PubServer(BaseHTTPRequestHandler): return blockDomain = self.path.split('/accountinfo?unblockdomain=')[1] blockDomain = urllib.parse.unquote_plus(blockDomain.strip()) + searchHandle = '' + if '?' in blockDomain: + searchHandle = '?' + blockDomain.split('?')[1] + blockDomain = blockDomain.split('?')[0] removeGlobalBlock(self.server.baseDir, nickname, blockDomain) self.server.GETbusy = False - # TODO this should go back to the account info screen - self._redirect_headers('/users/' + nickname + '/moderation', - cookie, callingDomain) + self._redirect_headers('/users/' + nickname + '/moderation' + + searchHandle, cookie, callingDomain) return # get the bookmarks timeline for a given person diff --git a/webapp_moderation.py b/webapp_moderation.py index 0b9783b37..35b362e7e 100644 --- a/webapp_moderation.py +++ b/webapp_moderation.py @@ -31,7 +31,7 @@ def htmlModeration(cssCache: {}, defaultTimeline: str, iconsAsButtons: bool, rssIconAtTop: bool, publishButtonAtTop: bool, - authorized: bool) -> str: + authorized: bool, moderationActionStr: str) -> str: """Show the moderation feed as html This is what you see when selecting the "mod" timeline """ @@ -45,7 +45,7 @@ def htmlModeration(cssCache: {}, defaultTimeline: str, newswire, False, False, positiveVoting, showPublishAsIcon, fullWidthTimelineButtonHeader, iconsAsButtons, rssIconAtTop, publishButtonAtTop, - authorized) + authorized, moderationActionStr) def htmlAccountInfo(cssCache: {}, translate: {}, diff --git a/webapp_timeline.py b/webapp_timeline.py index 43459c655..ca71c10d3 100644 --- a/webapp_timeline.py +++ b/webapp_timeline.py @@ -58,7 +58,8 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str, iconsAsButtons: bool, rssIconAtTop: bool, publishButtonAtTop: bool, - authorized: bool) -> str: + authorized: bool, + moderationActionStr: str) -> str: """Show the timeline as html """ enableTimingLog = False @@ -441,8 +442,13 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str, idx = 'Nickname or URL. Block using *@domain or nickname@domain' tlStr += \ ' ' + translate[idx] + '
\n' - tlStr += '
\n' + if moderationActionStr: + tlStr += '
\n' + else: + tlStr += '
\n' tlStr += \ '