mirror of https://gitlab.com/bashrc2/epicyon
Don't remove cached html if it is a reply to a blog post
parent
71915b8c94
commit
fbb7ed2a53
23
utils.py
23
utils.py
|
@ -403,6 +403,27 @@ def removeModerationPostFromIndex(baseDir: str, postUrl: str,
|
||||||
' from moderation index')
|
' from moderation index')
|
||||||
|
|
||||||
|
|
||||||
|
def isReplyToBlogPost(baseDir: str, nickname: str, domain: str,
|
||||||
|
postJsonObject: str):
|
||||||
|
"""Is the given post a reply to a blog post?
|
||||||
|
"""
|
||||||
|
if not postJsonObject.get('object'):
|
||||||
|
return False
|
||||||
|
if not isinstance(postJsonObject['object'], dict):
|
||||||
|
return False
|
||||||
|
if not postJsonObject['object'].get('inReplyTo'):
|
||||||
|
return False
|
||||||
|
blogsIndexFilename = baseDir + '/accounts/' + \
|
||||||
|
nickname + '@' + domain + '/tlblogs.index'
|
||||||
|
if not os.path.isfile(blogsIndexFilename):
|
||||||
|
return False
|
||||||
|
postId = postJsonObject['object']['inReplyTo'].replace('/activity', '')
|
||||||
|
postId = postId.replace('/', '#')
|
||||||
|
if postId in open(blogsIndexFilename).read():
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def deletePost(baseDir: str, httpPrefix: str,
|
def deletePost(baseDir: str, httpPrefix: str,
|
||||||
nickname: str, domain: str, postFilename: str,
|
nickname: str, domain: str, postFilename: str,
|
||||||
debug: bool) -> None:
|
debug: bool) -> None:
|
||||||
|
@ -432,6 +453,8 @@ def deletePost(baseDir: str, httpPrefix: str,
|
||||||
getCachedPostFilename(baseDir, nickname, domain, postJsonObject)
|
getCachedPostFilename(baseDir, nickname, domain, postJsonObject)
|
||||||
if cachedPostFilename:
|
if cachedPostFilename:
|
||||||
if os.path.isfile(cachedPostFilename):
|
if os.path.isfile(cachedPostFilename):
|
||||||
|
if not isReplyToBlogPost(baseDir, nickname, domain,
|
||||||
|
postJsonObject):
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
# removePostFromCache(postJsonObject,recentPostsCache)
|
# removePostFromCache(postJsonObject,recentPostsCache)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue