From cf8fe6c20e6288c3ca785661f03fe37bbccc129f Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 14 Jul 2019 16:10:31 +0100 Subject: [PATCH] Tidying --- inbox.py | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/inbox.py b/inbox.py index 920c871ea..74e0918ce 100644 --- a/inbox.py +++ b/inbox.py @@ -489,6 +489,23 @@ def receiveUndoLike(session,handle: str,baseDir: str, \ undoLikesCollectionEntry(postFilename,messageJson['object'],messageJson['actor'],debug) return True +def deletePost(baseDir: str,nickname: str,domain: str,postFilename: str,debug: bool): + """ + """ + repliesFilename=postFilename.replace('.json','.replies') + if os.path.isfile(repliesFilename): + if debug: + print('DEBUG: removing replies to '+postFilename) + with open(repliesFilename,'r') as f: + for replyId in f: + replyFile=locatePost(baseDir,nickname,domain,replyId) + if replyFile: + if os.path.isfile(replyFile): + os.remove(replyFile) + # remove the replies file itself + os.remove(repliesFilename) + os.remove(postFilename) + def receiveDelete(session,handle: str,baseDir: str, \ httpPrefix: str,domain :str,port: int, \ sendThreads: [],postLog: [],cachedWebfingers: {}, \ @@ -534,19 +551,7 @@ def receiveDelete(session,handle: str,baseDir: str, \ print('DEBUG: delete post not found in inbox or outbox') print(messageJson['object']) return True - repliesFilename=postFilename.replace('.json','.replies') - if os.path.isfile(repliesFilename): - if debug: - print('DEBUG: removing replies to '+postFilename) - with open(repliesFilename,'r') as f: - for replyId in f: - replyFile=locatePost(baseDir,handle.split('@')[0],handle.split('@')[1],replyId) - if replyFile: - if os.path.isfile(replyFile): - os.remove(replyFile) - # remove the replies file itself - os.remove(repliesFilename) - os.remove(postFilename) + deletePost(baseDir,handle.split('@')[0],handle.split('@')[1],postFilename,debug) if debug: print('DEBUG: post deleted - '+postFilename) return True