forked from indymedia/epicyon
Tidying
parent
3d6a363e6a
commit
cf8fe6c20e
31
inbox.py
31
inbox.py
|
@ -489,6 +489,23 @@ def receiveUndoLike(session,handle: str,baseDir: str, \
|
||||||
undoLikesCollectionEntry(postFilename,messageJson['object'],messageJson['actor'],debug)
|
undoLikesCollectionEntry(postFilename,messageJson['object'],messageJson['actor'],debug)
|
||||||
return True
|
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, \
|
def receiveDelete(session,handle: str,baseDir: str, \
|
||||||
httpPrefix: str,domain :str,port: int, \
|
httpPrefix: str,domain :str,port: int, \
|
||||||
sendThreads: [],postLog: [],cachedWebfingers: {}, \
|
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('DEBUG: delete post not found in inbox or outbox')
|
||||||
print(messageJson['object'])
|
print(messageJson['object'])
|
||||||
return True
|
return True
|
||||||
repliesFilename=postFilename.replace('.json','.replies')
|
deletePost(baseDir,handle.split('@')[0],handle.split('@')[1],postFilename,debug)
|
||||||
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)
|
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: post deleted - '+postFilename)
|
print('DEBUG: post deleted - '+postFilename)
|
||||||
return True
|
return True
|
||||||
|
|
Loading…
Reference in New Issue