Use calling domain when generating delete screen

merge-requests/8/head
Bob Mottram 2020-07-11 17:57:00 +01:00
parent 4b5040890a
commit e59796b426
2 changed files with 17 additions and 3 deletions

View File

@ -3164,7 +3164,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.session, self.server.baseDir, self.server.session, self.server.baseDir,
deleteUrl, self.server.httpPrefix, deleteUrl, self.server.httpPrefix,
__version__, self.server.cachedWebfingers, __version__, self.server.cachedWebfingers,
self.server.personCache) self.server.personCache, callingDomain)
if deleteStr: if deleteStr:
self._set_headers('text/html', len(deleteStr), self._set_headers('text/html', len(deleteStr),
cookie, callingDomain) cookie, callingDomain)

View File

@ -5112,7 +5112,8 @@ def htmlDeletePost(recentPostsCache: {}, maxRecentPosts: int,
translate, pageNumber: int, translate, pageNumber: int,
session, baseDir: str, messageId: str, session, baseDir: str, messageId: str,
httpPrefix: str, projectVersion: str, httpPrefix: str, projectVersion: str,
wfRequest: {}, personCache: {}) -> str: wfRequest: {}, personCache: {},
callingDomain: str) -> str:
"""Shows a screen asking to confirm the deletion of a post """Shows a screen asking to confirm the deletion of a post
""" """
if '/statuses/' not in messageId: if '/statuses/' not in messageId:
@ -5121,6 +5122,10 @@ def htmlDeletePost(recentPostsCache: {}, maxRecentPosts: int,
actor = messageId.split('/statuses/')[0] actor = messageId.split('/statuses/')[0]
nickname = getNicknameFromActor(actor) nickname = getNicknameFromActor(actor)
domain, port = getDomainFromActor(actor) domain, port = getDomainFromActor(actor)
domainFull = domain
if port:
if port != 80 and port != 443:
domainFull = domain + ':' + str(port)
postFilename = locatePost(baseDir, nickname, domain, messageId) postFilename = locatePost(baseDir, nickname, domain, messageId)
if not postFilename: if not postFilename:
@ -5157,7 +5162,16 @@ def htmlDeletePost(recentPostsCache: {}, maxRecentPosts: int,
deletePostStr += \ deletePostStr += \
' <p class="followText">' + \ ' <p class="followText">' + \
translate['Delete this post?'] + '</p>' translate['Delete this post?'] + '</p>'
deletePostStr += ' <form method="POST" action="' + actor + '/rmpost">' postActor = actor
if callingDomain not in actor and domainFull in actor:
if callingDomain.endswith('.onion') or \
callingDomain.endswith('.i2p'):
postActor = \
'http://' + callingDomain + actor.split(domainFull)[1]
print('Changed POST domain from ' + actor + ' to ' + postActor)
deletePostStr += \
' <form method="POST" action="' + postActor + '/rmpost">'
deletePostStr += \ deletePostStr += \
' <input type="hidden" name="pageNumber" value="' + \ ' <input type="hidden" name="pageNumber" value="' + \
str(pageNumber) + '">' str(pageNumber) + '">'