diff --git a/daemon.py b/daemon.py index 9c003649..112e5c9f 100644 --- a/daemon.py +++ b/daemon.py @@ -2386,7 +2386,8 @@ class PubServer(BaseHTTPRequestHandler): self.server.httpPrefix, self.server.domainFull, postId, postTime, - postYear, postMonth, postDay) + postYear, postMonth, postDay, + callingDomain) if not msg: actor = \ self.server.httpPrefix + '://' + \ diff --git a/webinterface.py b/webinterface.py index 59ef09d1..26683ac9 100644 --- a/webinterface.py +++ b/webinterface.py @@ -79,6 +79,19 @@ from petnames import getPetName from followingCalendar import receivingCalendarEvents +def getUrlPath(actor: str, domainFull: str, callingDomain: str) -> str: + """Returns path from url + """ + 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) + return postActor + + def getContentWarningButton(postID: str, translate: {}, content: str) -> str: """Returns the markup for a content warning button @@ -5162,14 +5175,8 @@ def htmlDeletePost(recentPostsCache: {}, maxRecentPosts: int, deletePostStr += \ '
' + \ translate['Delete this post?'] + '
' - 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) + postActor = getUrlPath(actor, domainFull, callingDomain) deletePostStr += \ '