Regenerate html for muted posts

main
Bob Mottram 2021-09-03 15:56:01 +01:00
parent 4347ff7574
commit 68c6241b44
1 changed files with 105 additions and 2 deletions

107
daemon.py
View File

@ -7137,13 +7137,13 @@ class PubServer(BaseHTTPRequestHandler):
domain, domain,
likeUrl) likeUrl)
if likedPostFilename: if likedPostFilename:
#if debug: # if debug:
print('Updating likes for ' + likedPostFilename) print('Updating likes for ' + likedPostFilename)
updateLikesCollection(self.server.recentPostsCache, updateLikesCollection(self.server.recentPostsCache,
baseDir, likedPostFilename, likeUrl, baseDir, likedPostFilename, likeUrl,
likeActor, self.postToNickname, domain, likeActor, self.postToNickname, domain,
debug) debug)
#if debug: # if debug:
print('Regenerating html post for changed likes collection') print('Regenerating html post for changed likes collection')
likedPostJson = loadJson(likedPostFilename, 0, 1) likedPostJson = loadJson(likedPostFilename, 0, 1)
if likedPostJson: if likedPostJson:
@ -7636,12 +7636,64 @@ class PubServer(BaseHTTPRequestHandler):
timelineStr = path.split('?tl=')[1] timelineStr = path.split('?tl=')[1]
if '?' in timelineStr: if '?' in timelineStr:
timelineStr = timelineStr.split('?')[0] timelineStr = timelineStr.split('?')[0]
pageNumber = 1
if '?page=' in path:
pageNumberStr = path.split('?page=')[1]
if '?' in pageNumberStr:
pageNumberStr = pageNumberStr.split('?')[0]
if '#' in pageNumberStr:
pageNumberStr = pageNumberStr.split('#')[0]
if pageNumberStr.isdigit():
pageNumber = int(pageNumberStr)
actor = \ actor = \
httpPrefix + '://' + domainFull + path.split('?mute=')[0] httpPrefix + '://' + domainFull + path.split('?mute=')[0]
nickname = getNicknameFromActor(actor) nickname = getNicknameFromActor(actor)
mutePost(baseDir, nickname, domain, port, mutePost(baseDir, nickname, domain, port,
httpPrefix, muteUrl, httpPrefix, muteUrl,
self.server.recentPostsCache, debug) self.server.recentPostsCache, debug)
muteFilename = locatePost(baseDir, nickname, domain, muteUrl)
if muteFilename:
print('Regenerating html post for changed mute status')
mutePostJson = loadJson(muteFilename, 0, 1)
if mutePostJson:
cachedPostFilename = \
getCachedPostFilename(baseDir, self.postToNickname,
domain, mutePostJson)
print('Muted post json: ' + str(mutePostJson))
print('Muted post nickname: ' +
self.postToNickname + ' ' + domain)
print('Muted post cache: ' + str(cachedPostFilename))
showIndividualPostIcons = True
manuallyApproveFollowers = \
followerApprovalActive(baseDir,
self.postToNickname, domain)
individualPostAsHtml(self.server.signingPrivateKeyPem, False,
self.server.recentPostsCache,
self.server.maxRecentPosts,
self.server.translate,
pageNumber, baseDir,
self.server.session,
self.server.cachedWebfingers,
self.server.personCache,
self.postToNickname, domain,
self.server.port, mutePostJson,
None, True,
self.server.allowDeletion,
httpPrefix, __version__, timelineStr,
self.server.YTReplacementDomain,
self.server.showPublishedDateOnly,
self.server.peertubeInstances,
self.server.allowLocalNetworkAccess,
self.server.themeName,
self.server.systemLanguage,
self.server.maxLikeCount,
not isDM(mutePostJson),
showIndividualPostIcons,
manuallyApproveFollowers,
False, True, False)
else:
print('WARN: Muted post not found: ' + muteFilename)
self.server.GETbusy = False self.server.GETbusy = False
if callingDomain.endswith('.onion') and onionDomain: if callingDomain.endswith('.onion') and onionDomain:
actor = \ actor = \
@ -7681,12 +7733,63 @@ class PubServer(BaseHTTPRequestHandler):
timelineStr = path.split('?tl=')[1] timelineStr = path.split('?tl=')[1]
if '?' in timelineStr: if '?' in timelineStr:
timelineStr = timelineStr.split('?')[0] timelineStr = timelineStr.split('?')[0]
pageNumber = 1
if '?page=' in path:
pageNumberStr = path.split('?page=')[1]
if '?' in pageNumberStr:
pageNumberStr = pageNumberStr.split('?')[0]
if '#' in pageNumberStr:
pageNumberStr = pageNumberStr.split('#')[0]
if pageNumberStr.isdigit():
pageNumber = int(pageNumberStr)
actor = \ actor = \
httpPrefix + '://' + domainFull + path.split('?unmute=')[0] httpPrefix + '://' + domainFull + path.split('?unmute=')[0]
nickname = getNicknameFromActor(actor) nickname = getNicknameFromActor(actor)
unmutePost(baseDir, nickname, domain, port, unmutePost(baseDir, nickname, domain, port,
httpPrefix, muteUrl, httpPrefix, muteUrl,
self.server.recentPostsCache, debug) self.server.recentPostsCache, debug)
muteFilename = locatePost(baseDir, nickname, domain, muteUrl)
if muteFilename:
print('Regenerating html post for changed unmute status')
mutePostJson = loadJson(muteFilename, 0, 1)
if mutePostJson:
cachedPostFilename = \
getCachedPostFilename(baseDir, self.postToNickname,
domain, mutePostJson)
print('Unmuted post json: ' + str(mutePostJson))
print('Unmuted post nickname: ' +
self.postToNickname + ' ' + domain)
print('Unmuted post cache: ' + str(cachedPostFilename))
showIndividualPostIcons = True
manuallyApproveFollowers = \
followerApprovalActive(baseDir,
self.postToNickname, domain)
individualPostAsHtml(self.server.signingPrivateKeyPem, False,
self.server.recentPostsCache,
self.server.maxRecentPosts,
self.server.translate,
pageNumber, baseDir,
self.server.session,
self.server.cachedWebfingers,
self.server.personCache,
self.postToNickname, domain,
self.server.port, mutePostJson,
None, True,
self.server.allowDeletion,
httpPrefix, __version__, timelineStr,
self.server.YTReplacementDomain,
self.server.showPublishedDateOnly,
self.server.peertubeInstances,
self.server.allowLocalNetworkAccess,
self.server.themeName,
self.server.systemLanguage,
self.server.maxLikeCount,
not isDM(mutePostJson),
showIndividualPostIcons,
manuallyApproveFollowers,
False, True, False)
else:
print('WARN: Unmuted post not found: ' + muteFilename)
self.server.GETbusy = False self.server.GETbusy = False
if callingDomain.endswith('.onion') and onionDomain: if callingDomain.endswith('.onion') and onionDomain:
actor = \ actor = \