mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
f294fbd356
commit
e65ad3bcc2
167
daemon.py
167
daemon.py
|
@ -7832,108 +7832,79 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
statusNumber = postSections[2]
|
||||
if len(statusNumber) <= 10 or (not statusNumber.isdigit()):
|
||||
return False
|
||||
postFilename = \
|
||||
baseDir + '/accounts/' + \
|
||||
nickname + '@' + \
|
||||
domain + '/outbox/' + \
|
||||
httpPrefix + ':##' + \
|
||||
domainFull + '#users#' + \
|
||||
nickname + '#statuses#' + \
|
||||
statusNumber + '.json'
|
||||
if os.path.isfile(postFilename):
|
||||
postJsonObject = loadJson(postFilename)
|
||||
if not postJsonObject:
|
||||
self.send_response(429)
|
||||
self.end_headers()
|
||||
self.server.GETbusy = False
|
||||
return True
|
||||
else:
|
||||
# Only authorized viewers get to see likes
|
||||
# on posts
|
||||
# Otherwize marketers could gain more social
|
||||
# graph info
|
||||
if not authorized:
|
||||
pjo = postJsonObject
|
||||
if not isPublicPost(pjo):
|
||||
self._404()
|
||||
self.server.GETbusy = False
|
||||
return True
|
||||
removePostInteractions(pjo, True)
|
||||
|
||||
if self._requestHTTP():
|
||||
recentPostsCache = \
|
||||
self.server.recentPostsCache
|
||||
maxRecentPosts = \
|
||||
self.server.maxRecentPosts
|
||||
translate = \
|
||||
self.server.translate
|
||||
cachedWebfingers = \
|
||||
self.server.cachedWebfingers
|
||||
personCache = \
|
||||
self.server.personCache
|
||||
projectVersion = \
|
||||
self.server.projectVersion
|
||||
ytDomain = \
|
||||
self.server.YTReplacementDomain
|
||||
showPublishedDateOnly = \
|
||||
self.server.showPublishedDateOnly
|
||||
peertubeInstances = \
|
||||
self.server.peertubeInstances
|
||||
allowLocalNetworkAccess = \
|
||||
self.server.allowLocalNetworkAccess
|
||||
themeName = \
|
||||
self.server.themeName
|
||||
msg = \
|
||||
htmlIndividualPost(self.server.cssCache,
|
||||
recentPostsCache,
|
||||
maxRecentPosts,
|
||||
translate,
|
||||
baseDir,
|
||||
self.server.session,
|
||||
cachedWebfingers,
|
||||
personCache,
|
||||
nickname,
|
||||
domain,
|
||||
port,
|
||||
authorized,
|
||||
postJsonObject,
|
||||
httpPrefix,
|
||||
projectVersion,
|
||||
likedBy,
|
||||
ytDomain,
|
||||
showPublishedDateOnly,
|
||||
peertubeInstances,
|
||||
allowLocalNetworkAccess,
|
||||
themeName)
|
||||
msg = msg.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
self._set_headers('text/html', msglen,
|
||||
cookie, callingDomain)
|
||||
self._write(msg)
|
||||
self._benchmarkGETtimings(GETstartTime,
|
||||
GETtimings,
|
||||
'show skills ' +
|
||||
'done',
|
||||
'show status')
|
||||
else:
|
||||
if self._fetchAuthenticated():
|
||||
msg = json.dumps(postJsonObject,
|
||||
ensure_ascii=False)
|
||||
msg = msg.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
self._set_headers('application/json',
|
||||
msglen,
|
||||
None, callingDomain)
|
||||
self._write(msg)
|
||||
else:
|
||||
self._404()
|
||||
self.server.GETbusy = False
|
||||
return True
|
||||
else:
|
||||
postFilename = \
|
||||
baseDir + '/accounts/' + nickname + '@' + domain + '/outbox/' + \
|
||||
httpPrefix + ':##' + domainFull + '#users#' + nickname + \
|
||||
'#statuses#' + statusNumber + '.json'
|
||||
if not os.path.isfile(postFilename):
|
||||
self._404()
|
||||
self.server.GETbusy = False
|
||||
return True
|
||||
return False
|
||||
|
||||
postJsonObject = loadJson(postFilename)
|
||||
if not postJsonObject:
|
||||
self.send_response(429)
|
||||
self.end_headers()
|
||||
self.server.GETbusy = False
|
||||
return True
|
||||
|
||||
# Only authorized viewers get to see likes
|
||||
# on posts
|
||||
# Otherwize marketers could gain more social
|
||||
# graph info
|
||||
if not authorized:
|
||||
pjo = postJsonObject
|
||||
if not isPublicPost(pjo):
|
||||
self._404()
|
||||
self.server.GETbusy = False
|
||||
return True
|
||||
removePostInteractions(pjo, True)
|
||||
if self._requestHTTP():
|
||||
msg = \
|
||||
htmlIndividualPost(self.server.cssCache,
|
||||
self.server.recentPostsCache,
|
||||
self.server.maxRecentPosts,
|
||||
self.server.translate,
|
||||
baseDir,
|
||||
self.server.session,
|
||||
self.server.cachedWebfingers,
|
||||
self.server.personCache,
|
||||
nickname, domain, port,
|
||||
authorized,
|
||||
postJsonObject,
|
||||
httpPrefix,
|
||||
self.server.projectVersion,
|
||||
likedBy,
|
||||
self.server.YTReplacementDomain,
|
||||
self.server.showPublishedDateOnly,
|
||||
self.server.peertubeInstances,
|
||||
self.server.allowLocalNetworkAccess,
|
||||
self.server.themeName)
|
||||
msg = msg.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
self._set_headers('text/html', msglen,
|
||||
cookie, callingDomain)
|
||||
self._write(msg)
|
||||
self._benchmarkGETtimings(GETstartTime,
|
||||
GETtimings,
|
||||
'show skills ' +
|
||||
'done',
|
||||
'show status')
|
||||
else:
|
||||
if self._fetchAuthenticated():
|
||||
msg = json.dumps(postJsonObject,
|
||||
ensure_ascii=False)
|
||||
msg = msg.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
self._set_headers('application/json',
|
||||
msglen,
|
||||
None, callingDomain)
|
||||
self._write(msg)
|
||||
else:
|
||||
self._404()
|
||||
self.server.GETbusy = False
|
||||
return True
|
||||
|
||||
def _showInbox(self, authorized: bool,
|
||||
callingDomain: str, path: str,
|
||||
|
|
Loading…
Reference in New Issue