Override moderator flag for news timeline

merge-requests/30/head
Bob Mottram 2020-10-07 21:46:37 +01:00
parent 251a7efcd6
commit da8e2733be
2 changed files with 17 additions and 15 deletions

View File

@ -6539,6 +6539,7 @@ class PubServer(BaseHTTPRequestHandler):
currNickname = path.split('/users/')[1] currNickname = path.split('/users/')[1]
if '/' in currNickname: if '/' in currNickname:
currNickname = currNickname.split('/')[0] currNickname = currNickname.split('/')[0]
moderator = isModerator(baseDir, currNickname)
msg = \ msg = \
htmlInboxNews(self.server.defaultTimeline, htmlInboxNews(self.server.defaultTimeline,
self.server.recentPostsCache, self.server.recentPostsCache,
@ -6558,7 +6559,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.projectVersion, self.server.projectVersion,
self._isMinimal(nickname), self._isMinimal(nickname),
self.server.YTReplacementDomain, self.server.YTReplacementDomain,
self.server.newswire) self.server.newswire, moderator)
msg = msg.replace('/news/', '/' + currNickname + '/') msg = msg.replace('/news/', '/' + currNickname + '/')
msg = msg.replace('/banner.webp', '/banner.png') msg = msg.replace('/banner.webp', '/banner.png')
msg = msg.encode('utf-8') msg = msg.encode('utf-8')

View File

@ -5504,7 +5504,7 @@ def htmlTimeline(defaultTimeline: str,
manuallyApproveFollowers: bool, manuallyApproveFollowers: bool,
minimal: bool, minimal: bool,
YTReplacementDomain: str, YTReplacementDomain: str,
newswire: {}) -> str: newswire: {}, moderator: bool) -> str:
"""Show the timeline as html """Show the timeline as html
""" """
timelineStartTime = time.time() timelineStartTime = time.time()
@ -5600,6 +5600,7 @@ def htmlTimeline(defaultTimeline: str,
httpPrefix + '://') httpPrefix + '://')
# is the user a moderator? # is the user a moderator?
if not moderator:
moderator = isModerator(baseDir, nickname) moderator = isModerator(baseDir, nickname)
# benchmark 2 # benchmark 2
@ -6192,7 +6193,7 @@ def htmlShares(defaultTimeline: str,
nickname, domain, port, None, nickname, domain, port, None,
'tlshares', allowDeletion, 'tlshares', allowDeletion,
httpPrefix, projectVersion, manuallyApproveFollowers, httpPrefix, projectVersion, manuallyApproveFollowers,
False, YTReplacementDomain, newswire) False, YTReplacementDomain, newswire, False)
def htmlInbox(defaultTimeline: str, def htmlInbox(defaultTimeline: str,
@ -6215,7 +6216,7 @@ def htmlInbox(defaultTimeline: str,
nickname, domain, port, inboxJson, nickname, domain, port, inboxJson,
'inbox', allowDeletion, 'inbox', allowDeletion,
httpPrefix, projectVersion, manuallyApproveFollowers, httpPrefix, projectVersion, manuallyApproveFollowers,
minimal, YTReplacementDomain, newswire) minimal, YTReplacementDomain, newswire, False)
def htmlBookmarks(defaultTimeline: str, def htmlBookmarks(defaultTimeline: str,
@ -6238,7 +6239,7 @@ def htmlBookmarks(defaultTimeline: str,
nickname, domain, port, bookmarksJson, nickname, domain, port, bookmarksJson,
'tlbookmarks', allowDeletion, 'tlbookmarks', allowDeletion,
httpPrefix, projectVersion, manuallyApproveFollowers, httpPrefix, projectVersion, manuallyApproveFollowers,
minimal, YTReplacementDomain, newswire) minimal, YTReplacementDomain, newswire, False)
def htmlEvents(defaultTimeline: str, def htmlEvents(defaultTimeline: str,
@ -6261,7 +6262,7 @@ def htmlEvents(defaultTimeline: str,
nickname, domain, port, bookmarksJson, nickname, domain, port, bookmarksJson,
'tlevents', allowDeletion, 'tlevents', allowDeletion,
httpPrefix, projectVersion, manuallyApproveFollowers, httpPrefix, projectVersion, manuallyApproveFollowers,
minimal, YTReplacementDomain, newswire) minimal, YTReplacementDomain, newswire, False)
def htmlInboxDMs(defaultTimeline: str, def htmlInboxDMs(defaultTimeline: str,
@ -6280,7 +6281,7 @@ def htmlInboxDMs(defaultTimeline: str,
itemsPerPage, session, baseDir, wfRequest, personCache, itemsPerPage, session, baseDir, wfRequest, personCache,
nickname, domain, port, inboxJson, 'dm', allowDeletion, nickname, domain, port, inboxJson, 'dm', allowDeletion,
httpPrefix, projectVersion, False, minimal, httpPrefix, projectVersion, False, minimal,
YTReplacementDomain, newswire) YTReplacementDomain, newswire, False)
def htmlInboxReplies(defaultTimeline: str, def htmlInboxReplies(defaultTimeline: str,
@ -6299,7 +6300,7 @@ def htmlInboxReplies(defaultTimeline: str,
itemsPerPage, session, baseDir, wfRequest, personCache, itemsPerPage, session, baseDir, wfRequest, personCache,
nickname, domain, port, inboxJson, 'tlreplies', nickname, domain, port, inboxJson, 'tlreplies',
allowDeletion, httpPrefix, projectVersion, False, allowDeletion, httpPrefix, projectVersion, False,
minimal, YTReplacementDomain, newswire) minimal, YTReplacementDomain, newswire, False)
def htmlInboxMedia(defaultTimeline: str, def htmlInboxMedia(defaultTimeline: str,
@ -6318,7 +6319,7 @@ def htmlInboxMedia(defaultTimeline: str,
itemsPerPage, session, baseDir, wfRequest, personCache, itemsPerPage, session, baseDir, wfRequest, personCache,
nickname, domain, port, inboxJson, 'tlmedia', nickname, domain, port, inboxJson, 'tlmedia',
allowDeletion, httpPrefix, projectVersion, False, allowDeletion, httpPrefix, projectVersion, False,
minimal, YTReplacementDomain, newswire) minimal, YTReplacementDomain, newswire, False)
def htmlInboxBlogs(defaultTimeline: str, def htmlInboxBlogs(defaultTimeline: str,
@ -6337,7 +6338,7 @@ def htmlInboxBlogs(defaultTimeline: str,
itemsPerPage, session, baseDir, wfRequest, personCache, itemsPerPage, session, baseDir, wfRequest, personCache,
nickname, domain, port, inboxJson, 'tlblogs', nickname, domain, port, inboxJson, 'tlblogs',
allowDeletion, httpPrefix, projectVersion, False, allowDeletion, httpPrefix, projectVersion, False,
minimal, YTReplacementDomain, newswire) minimal, YTReplacementDomain, newswire, False)
def htmlInboxNews(defaultTimeline: str, def htmlInboxNews(defaultTimeline: str,
@ -6348,7 +6349,7 @@ def htmlInboxNews(defaultTimeline: str,
allowDeletion: bool, allowDeletion: bool,
httpPrefix: str, projectVersion: str, httpPrefix: str, projectVersion: str,
minimal: bool, YTReplacementDomain: str, minimal: bool, YTReplacementDomain: str,
newswire: {}) -> str: newswire: {}, moderator: bool) -> str:
"""Show the news timeline as html """Show the news timeline as html
""" """
return htmlTimeline(defaultTimeline, recentPostsCache, maxRecentPosts, return htmlTimeline(defaultTimeline, recentPostsCache, maxRecentPosts,
@ -6356,7 +6357,7 @@ def htmlInboxNews(defaultTimeline: str,
itemsPerPage, session, baseDir, wfRequest, personCache, itemsPerPage, session, baseDir, wfRequest, personCache,
nickname, domain, port, inboxJson, 'tlnews', nickname, domain, port, inboxJson, 'tlnews',
allowDeletion, httpPrefix, projectVersion, False, allowDeletion, httpPrefix, projectVersion, False,
minimal, YTReplacementDomain, newswire) minimal, YTReplacementDomain, newswire, moderator)
def htmlModeration(defaultTimeline: str, def htmlModeration(defaultTimeline: str,
@ -6375,7 +6376,7 @@ def htmlModeration(defaultTimeline: str,
itemsPerPage, session, baseDir, wfRequest, personCache, itemsPerPage, session, baseDir, wfRequest, personCache,
nickname, domain, port, inboxJson, 'moderation', nickname, domain, port, inboxJson, 'moderation',
allowDeletion, httpPrefix, projectVersion, True, False, allowDeletion, httpPrefix, projectVersion, True, False,
YTReplacementDomain, newswire) YTReplacementDomain, newswire, False)
def htmlOutbox(defaultTimeline: str, def htmlOutbox(defaultTimeline: str,
@ -6397,7 +6398,7 @@ def htmlOutbox(defaultTimeline: str,
nickname, domain, port, outboxJson, 'outbox', nickname, domain, port, outboxJson, 'outbox',
allowDeletion, httpPrefix, projectVersion, allowDeletion, httpPrefix, projectVersion,
manuallyApproveFollowers, minimal, manuallyApproveFollowers, minimal,
YTReplacementDomain, newswire) YTReplacementDomain, newswire, False)
def htmlIndividualPost(recentPostsCache: {}, maxRecentPosts: int, def htmlIndividualPost(recentPostsCache: {}, maxRecentPosts: int,