mirror of https://gitlab.com/bashrc2/epicyon
Move new post to its own module
parent
632d2977dd
commit
38f9f91664
94
daemon.py
94
daemon.py
|
@ -626,7 +626,6 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
if not self._write(msg):
|
if not self._write(msg):
|
||||||
print('Error when showing ' + str(httpCode))
|
print('Error when showing ' + str(httpCode))
|
||||||
print(e)
|
|
||||||
|
|
||||||
def _200(self) -> None:
|
def _200(self) -> None:
|
||||||
if self.server.translate:
|
if self.server.translate:
|
||||||
|
@ -7134,6 +7133,53 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.GETbusy = False
|
self.server.GETbusy = False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def _showNewPost(self, callingDomain: str, path: str,
|
||||||
|
mediaInstance: bool, translate: {},
|
||||||
|
baseDir: str, httpPrefix: str,
|
||||||
|
inReplyToUrl: str, replyToList: [],
|
||||||
|
shareDescription: str, replyPageNumber: int,
|
||||||
|
domain: str, domainFull: str,
|
||||||
|
GETstartTime, GETtimings: {}, cookie) -> bool:
|
||||||
|
"""Shows the new post screen
|
||||||
|
"""
|
||||||
|
isNewPostEndpoint = False
|
||||||
|
if '/users/' in path and '/new' in path:
|
||||||
|
# Various types of new post in the web interface
|
||||||
|
newPostEnd = ('newpost', 'newblog', 'newunlisted',
|
||||||
|
'newfollowers', 'newdm', 'newreminder',
|
||||||
|
'newevent', 'newreport', 'newquestion',
|
||||||
|
'newshare')
|
||||||
|
for postType in newPostEnd:
|
||||||
|
if path.endswith('/' + postType):
|
||||||
|
isNewPostEndpoint = True
|
||||||
|
break
|
||||||
|
if isNewPostEndpoint:
|
||||||
|
nickname = getNicknameFromActor(path)
|
||||||
|
msg = htmlNewPost(mediaInstance,
|
||||||
|
translate,
|
||||||
|
baseDir,
|
||||||
|
httpPrefix,
|
||||||
|
path, inReplyToUrl,
|
||||||
|
replyToList,
|
||||||
|
shareDescription,
|
||||||
|
replyPageNumber,
|
||||||
|
nickname, domain,
|
||||||
|
domainFull).encode('utf-8')
|
||||||
|
if not msg:
|
||||||
|
print('Error replying to ' + inReplyToUrl)
|
||||||
|
self._404()
|
||||||
|
self.server.GETbusy = False
|
||||||
|
return True
|
||||||
|
self._set_headers('text/html', len(msg),
|
||||||
|
cookie, callingDomain)
|
||||||
|
self._write(msg)
|
||||||
|
self.server.GETbusy = False
|
||||||
|
self._benchmarkGETtimings(GETstartTime, GETtimings,
|
||||||
|
'unmute activated done',
|
||||||
|
'new post made')
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def do_GET(self):
|
def do_GET(self):
|
||||||
callingDomain = self.server.domainFull
|
callingDomain = self.server.domainFull
|
||||||
if self.headers.get('Host'):
|
if self.headers.get('Host'):
|
||||||
|
@ -8403,41 +8449,17 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.GETbusy = False
|
self.server.GETbusy = False
|
||||||
return
|
return
|
||||||
|
|
||||||
# Various types of new post in the web interface
|
if self._showNewPost(callingDomain, self.path,
|
||||||
if ('/users/' in self.path and
|
self.server.mediaInstance,
|
||||||
(self.path.endswith('/newpost') or
|
self.server.translate,
|
||||||
self.path.endswith('/newblog') or
|
self.server.baseDir,
|
||||||
self.path.endswith('/newunlisted') or
|
self.server.httpPrefix,
|
||||||
self.path.endswith('/newfollowers') or
|
inReplyToUrl, replyToList,
|
||||||
self.path.endswith('/newdm') or
|
shareDescription, replyPageNumber,
|
||||||
self.path.endswith('/newreminder') or
|
self.server.domain,
|
||||||
self.path.endswith('/newevent') or
|
self.server.domainFull,
|
||||||
self.path.endswith('/newreport') or
|
GETstartTime, GETtimings,
|
||||||
self.path.endswith('/newquestion') or
|
cookie):
|
||||||
self.path.endswith('/newshare'))):
|
|
||||||
nickname = getNicknameFromActor(self.path)
|
|
||||||
msg = htmlNewPost(self.server.mediaInstance,
|
|
||||||
self.server.translate,
|
|
||||||
self.server.baseDir,
|
|
||||||
self.server.httpPrefix,
|
|
||||||
self.path, inReplyToUrl,
|
|
||||||
replyToList,
|
|
||||||
shareDescription,
|
|
||||||
replyPageNumber,
|
|
||||||
nickname, self.server.domain,
|
|
||||||
self.server.domainFull).encode('utf-8')
|
|
||||||
if not msg:
|
|
||||||
print('Error replying to ' + inReplyToUrl)
|
|
||||||
self._404()
|
|
||||||
self.server.GETbusy = False
|
|
||||||
return
|
|
||||||
self._set_headers('text/html', len(msg),
|
|
||||||
cookie, callingDomain)
|
|
||||||
self._write(msg)
|
|
||||||
self.server.GETbusy = False
|
|
||||||
self._benchmarkGETtimings(GETstartTime, GETtimings,
|
|
||||||
'unmute activated done',
|
|
||||||
'new post made')
|
|
||||||
return
|
return
|
||||||
|
|
||||||
self._benchmarkGETtimings(GETstartTime, GETtimings,
|
self._benchmarkGETtimings(GETstartTime, GETtimings,
|
||||||
|
|
Loading…
Reference in New Issue