Delete cached post for muted announces

main
Bob Mottram 2021-09-28 17:32:54 +01:00
parent 29ac6e95ff
commit 266bdc0fe5
1 changed files with 30 additions and 0 deletions

View File

@ -556,6 +556,21 @@ def mutePost(baseDir: str, nickname: str, domain: str, port: int,
print('MUTE: ' + postId + ' removed cached html')
if alsoUpdatePostId:
postFilename = locatePost(baseDir, nickname, domain, alsoUpdatePostId)
if os.path.isfile(postFilename):
postJsonObj = loadJson(postFilename)
cachedPostFilename = \
getCachedPostFilename(baseDir, nickname, domain,
postJsonObj)
if cachedPostFilename:
if os.path.isfile(cachedPostFilename):
try:
os.remove(cachedPostFilename)
print('MUTE: cached referenced post removed ' +
cachedPostFilename)
except BaseException:
pass
if recentPostsCache.get('json'):
if recentPostsCache['json'].get(alsoUpdatePostId):
del recentPostsCache['json'][alsoUpdatePostId]
@ -649,6 +664,21 @@ def unmutePost(baseDir: str, nickname: str, domain: str, port: int,
del recentPostsCache['html'][postId]
print('UNMUTE: ' + postId + ' removed cached html')
if alsoUpdatePostId:
postFilename = locatePost(baseDir, nickname, domain, alsoUpdatePostId)
if os.path.isfile(postFilename):
postJsonObj = loadJson(postFilename)
cachedPostFilename = \
getCachedPostFilename(baseDir, nickname, domain,
postJsonObj)
if cachedPostFilename:
if os.path.isfile(cachedPostFilename):
try:
os.remove(cachedPostFilename)
print('MUTE: cached referenced post removed ' +
cachedPostFilename)
except BaseException:
pass
if recentPostsCache.get('json'):
if recentPostsCache['json'].get(alsoUpdatePostId):
del recentPostsCache['json'][alsoUpdatePostId]