mirror of https://gitlab.com/bashrc2/epicyon
Less indentation
parent
e65ad3bcc2
commit
f6355632ec
182
daemon.py
182
daemon.py
|
@ -7700,111 +7700,85 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if '/' not in namedStatus:
|
if '/' not in namedStatus:
|
||||||
# show actor
|
# show actor
|
||||||
nickname = namedStatus
|
nickname = namedStatus
|
||||||
|
return False
|
||||||
|
|
||||||
|
postSections = namedStatus.split('/')
|
||||||
|
if len(postSections) != 2:
|
||||||
|
return False
|
||||||
|
nickname = postSections[0]
|
||||||
|
statusNumber = postSections[1]
|
||||||
|
if len(statusNumber) <= 10 or not statusNumber.isdigit():
|
||||||
|
return False
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
postJsonObject = loadJson(postFilename)
|
||||||
|
loadedPost = False
|
||||||
|
if postJsonObject:
|
||||||
|
loadedPost = True
|
||||||
else:
|
else:
|
||||||
postSections = namedStatus.split('/')
|
postJsonObject = {}
|
||||||
if len(postSections) == 2:
|
if loadedPost:
|
||||||
nickname = postSections[0]
|
# Only authorized viewers get to see likes
|
||||||
statusNumber = postSections[1]
|
# on posts. Otherwize marketers could gain
|
||||||
if len(statusNumber) > 10 and statusNumber.isdigit():
|
# more social graph info
|
||||||
postFilename = \
|
if not authorized:
|
||||||
baseDir + '/accounts/' + \
|
pjo = postJsonObject
|
||||||
nickname + '@' + \
|
if not isPublicPost(pjo):
|
||||||
domain + '/outbox/' + \
|
self._404()
|
||||||
httpPrefix + ':##' + \
|
self.server.GETbusy = False
|
||||||
domainFull + '#users#' + \
|
return True
|
||||||
nickname + '#statuses#' + \
|
removePostInteractions(pjo, True)
|
||||||
statusNumber + '.json'
|
if self._requestHTTP():
|
||||||
if os.path.isfile(postFilename):
|
msg = \
|
||||||
postJsonObject = loadJson(postFilename)
|
htmlIndividualPost(self.server.cssCache,
|
||||||
loadedPost = False
|
self.server.recentPostsCache,
|
||||||
if postJsonObject:
|
self.server.maxRecentPosts,
|
||||||
loadedPost = True
|
self.server.translate,
|
||||||
else:
|
self.server.baseDir,
|
||||||
postJsonObject = {}
|
self.server.session,
|
||||||
if loadedPost:
|
self.server.cachedWebfingers,
|
||||||
# Only authorized viewers get to see likes
|
self.server.personCache,
|
||||||
# on posts. Otherwize marketers could gain
|
nickname, domain, port,
|
||||||
# more social graph info
|
authorized,
|
||||||
if not authorized:
|
postJsonObject,
|
||||||
pjo = postJsonObject
|
httpPrefix,
|
||||||
if not isPublicPost(pjo):
|
self.server.projectVersion,
|
||||||
self._404()
|
likedBy,
|
||||||
self.server.GETbusy = False
|
self.server.YTReplacementDomain,
|
||||||
return True
|
self.server.showPublishedDateOnly,
|
||||||
removePostInteractions(pjo, True)
|
self.server.peertubeInstances,
|
||||||
if self._requestHTTP():
|
self.server.allowLocalNetworkAccess,
|
||||||
recentPostsCache = \
|
self.server.themeName)
|
||||||
self.server.recentPostsCache
|
msg = msg.encode('utf-8')
|
||||||
maxRecentPosts = \
|
msglen = len(msg)
|
||||||
self.server.maxRecentPosts
|
self._set_headers('text/html', msglen,
|
||||||
translate = \
|
cookie, callingDomain)
|
||||||
self.server.translate
|
self._write(msg)
|
||||||
cachedWebfingers = \
|
else:
|
||||||
self.server.cachedWebfingers
|
if self._fetchAuthenticated():
|
||||||
personCache = \
|
msg = json.dumps(postJsonObject,
|
||||||
self.server.personCache
|
ensure_ascii=False)
|
||||||
projectVersion = \
|
msg = msg.encode('utf-8')
|
||||||
self.server.projectVersion
|
msglen = len(msg)
|
||||||
ytDomain = \
|
self._set_headers('application/json',
|
||||||
self.server.YTReplacementDomain
|
msglen,
|
||||||
showPublishedDateOnly = \
|
None, callingDomain)
|
||||||
self.server.showPublishedDateOnly
|
self._write(msg)
|
||||||
peertubeInstances = \
|
else:
|
||||||
self.server.peertubeInstances
|
self._404()
|
||||||
cssCache = self.server.cssCache
|
self.server.GETbusy = False
|
||||||
allowLocalNetworkAccess = \
|
self._benchmarkGETtimings(GETstartTime, GETtimings,
|
||||||
self.server.allowLocalNetworkAccess
|
'new post done',
|
||||||
themeName = \
|
'individual post shown')
|
||||||
self.server.themeName
|
return True
|
||||||
msg = \
|
|
||||||
htmlIndividualPost(cssCache,
|
|
||||||
recentPostsCache,
|
|
||||||
maxRecentPosts,
|
|
||||||
translate,
|
|
||||||
self.server.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)
|
|
||||||
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
|
|
||||||
self._benchmarkGETtimings(GETstartTime, GETtimings,
|
|
||||||
'new post done',
|
|
||||||
'individual post shown')
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
self._404()
|
|
||||||
self.server.GETbusy = False
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
def _showIndividualPost(self, authorized: bool,
|
def _showIndividualPost(self, authorized: bool,
|
||||||
callingDomain: str, path: str,
|
callingDomain: str, path: str,
|
||||||
|
|
Loading…
Reference in New Issue