Delete button also removed blogs from the news actor

main
Bob Mottram 2020-11-27 10:38:51 +00:00
parent e3e88de0d8
commit 020c7a1314
2 changed files with 20 additions and 7 deletions

View File

@ -2748,7 +2748,7 @@ class PubServer(BaseHTTPRequestHandler):
domain: str, domainFull: str, domain: str, domainFull: str,
onionDomain: str, i2pDomain: str, onionDomain: str, i2pDomain: str,
debug: bool) -> None: debug: bool) -> None:
"""Endpoint for removing posts """Endpoint for removing posts after confirmation
""" """
pageNumber = 1 pageNumber = 1
usersPath = path.split('/rmpost')[0] usersPath = path.split('/rmpost')[0]
@ -2812,7 +2812,7 @@ class PubServer(BaseHTTPRequestHandler):
'actor': removePostActor, 'actor': removePostActor,
'object': removeMessageId, 'object': removeMessageId,
'to': toList, 'to': toList,
'cc': [removePostActor+'/followers'], 'cc': [removePostActor + '/followers'],
'type': 'Delete' 'type': 'Delete'
} }
self.postToNickname = getNicknameFromActor(removePostActor) self.postToNickname = getNicknameFromActor(removePostActor)
@ -5809,7 +5809,7 @@ class PubServer(BaseHTTPRequestHandler):
GETstartTime, GETtimings: {}, GETstartTime, GETtimings: {},
proxyType: str, cookie: str, proxyType: str, cookie: str,
debug: str): debug: str):
"""Delete button is pressed """Delete button is pressed on a post
""" """
if not cookie: if not cookie:
print('ERROR: no cookie given when deleting') print('ERROR: no cookie given when deleting')

View File

@ -1251,18 +1251,31 @@ def receiveDelete(session, handle: str, isGroup: bool, baseDir: str,
# if this post in the outbox of the person? # if this post in the outbox of the person?
messageId = removeIdEnding(messageJson['object']) messageId = removeIdEnding(messageJson['object'])
removeModerationPostFromIndex(baseDir, messageId, debug) removeModerationPostFromIndex(baseDir, messageId, debug)
postFilename = locatePost(baseDir, handle.split('@')[0], handleNickname = handle.split('@')[0]
handle.split('@')[1], messageId) handleDomain = handle.split('@')[1]
postFilename = locatePost(baseDir, handleNickname,
handleDomain, messageId)
if not postFilename: if not postFilename:
if debug: if debug:
print('DEBUG: delete post not found in inbox or outbox') print('DEBUG: delete post not found in inbox or outbox')
print(messageId) print(messageId)
return True return True
deletePost(baseDir, httpPrefix, handle.split('@')[0], deletePost(baseDir, httpPrefix, handleNickname,
handle.split('@')[1], postFilename, debug, handleDomain, postFilename, debug,
recentPostsCache) recentPostsCache)
if debug: if debug:
print('DEBUG: post deleted - ' + postFilename) print('DEBUG: post deleted - ' + postFilename)
# also delete any local blogs saved to the news actor
if handleNickname != 'news' and handleDomain == domainFull:
postFilename = locatePost(baseDir, 'news',
handleDomain, messageId)
if postFilename:
deletePost(baseDir, httpPrefix, 'news',
handleDomain, postFilename, debug,
recentPostsCache)
if debug:
print('DEBUG: blog post deleted - ' + postFilename)
return True return True