master
Bob Mottram 2019-07-14 16:10:31 +01:00
parent 3d6a363e6a
commit cf8fe6c20e
1 changed files with 18 additions and 13 deletions

View File

@ -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