From 8d4f6ea60a8cd12cea653a347b00db9dcf88d99a Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 17 Nov 2019 15:19:34 +0000 Subject: [PATCH] Don't delete bookmarked posts --- utils.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/utils.py b/utils.py index 5c7ea5713..23c3ebe81 100644 --- a/utils.py +++ b/utils.py @@ -296,7 +296,7 @@ def removeModerationPostFromIndex(baseDir: str,postUrl: str,debug: bool) -> None if debug: print('DEBUG: removed '+postId+' from moderation index') -def deletePost(baseDir: str,httpPrefix: str,nickname: str,domain: str,postFilename: str,debug: bool): +def deletePost(baseDir: str,httpPrefix: str,nickname: str,domain: str,postFilename: str,debug: bool) -> None: """Recursively deletes a post and its replies and attachments """ postJsonObject=None @@ -312,6 +312,13 @@ def deletePost(baseDir: str,httpPrefix: str,nickname: str,domain: str,postFilena tries+=1 if postJsonObject: + # don't allow deletion of bookmarked posts + bookmarksIndexFilename=baseDir+'/accounts/'+nickname+'@'+domain+'/bookmarks.index' + if os.path.isfile(bookmarksIndexFilename): + bookmarkIndex=postFilename.split('/')[-1]+'\n' + if bookmarkIndex in open(bookmarksIndexFilename).read(): + return + # remove any attachment removeAttachment(baseDir,httpPrefix,domain,postJsonObject)