Redirect after post

master
Bob Mottram 2019-07-28 15:09:48 +01:00
parent fcf8399b5a
commit f81ca9d66d
1 changed files with 12 additions and 10 deletions

View File

@ -109,6 +109,13 @@ class PubServer(BaseHTTPRequestHandler):
self.send_header('Host', self.server.domainFull) self.send_header('Host', self.server.domainFull)
self.end_headers() self.end_headers()
def _redirect_headers(self,redirect: str) -> None:
self.send_response(303)
self.send_header('Content-type', 'text/html')
self.send_header('Location', redirect)
self.send_header('Host', self.server.domainFull)
self.end_headers()
def _404(self) -> None: def _404(self) -> None:
self.send_response(404) self.send_response(404)
self.send_header('Content-Type', 'text/html; charset=utf-8') self.send_header('Content-Type', 'text/html; charset=utf-8')
@ -1317,28 +1324,23 @@ class PubServer(BaseHTTPRequestHandler):
return return
if self._receiveNewPost(authorized,'newpost'): if self._receiveNewPost(authorized,'newpost'):
self.send_response(200) self._redirect_headers('/users/'+self.postToNickname+'/outbox')
self.end_headers()
self.server.POSTbusy=False self.server.POSTbusy=False
return return
elif self._receiveNewPost(authorized,'newunlisted'): elif self._receiveNewPost(authorized,'newunlisted'):
self.send_response(200) self._redirect_headers('/users/'+self.postToNickname+'/outbox')
self.end_headers()
self.server.POSTbusy=False self.server.POSTbusy=False
return return
elif self._receiveNewPost(authorized,'newfollowers'): elif self._receiveNewPost(authorized,'newfollowers'):
self.send_response(200) self._redirect_headers('/users/'+self.postToNickname+'/outbox')
self.end_headers()
self.server.POSTbusy=False self.server.POSTbusy=False
return return
elif self._receiveNewPost(authorized,'newdm'): elif self._receiveNewPost(authorized,'newdm'):
self.send_response(200) self._redirect_headers('/users/'+self.postToNickname+'/outbox')
self.end_headers()
self.server.POSTbusy=False self.server.POSTbusy=False
return return
elif self._receiveNewPost(authorized,'newshare'): elif self._receiveNewPost(authorized,'newshare'):
self.send_response(200) self._redirect_headers('/users/'+self.postToNickname+'/shares')
self.end_headers()
self.server.POSTbusy=False self.server.POSTbusy=False
return return