main
Bob Mottram 2021-07-07 12:03:16 +01:00
parent f294fbd356
commit e65ad3bcc2
1 changed files with 69 additions and 98 deletions

167
daemon.py
View File

@ -7832,108 +7832,79 @@ class PubServer(BaseHTTPRequestHandler):
statusNumber = postSections[2] statusNumber = postSections[2]
if len(statusNumber) <= 10 or (not statusNumber.isdigit()): if len(statusNumber) <= 10 or (not statusNumber.isdigit()):
return False 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(): postFilename = \
recentPostsCache = \ baseDir + '/accounts/' + nickname + '@' + domain + '/outbox/' + \
self.server.recentPostsCache httpPrefix + ':##' + domainFull + '#users#' + nickname + \
maxRecentPosts = \ '#statuses#' + statusNumber + '.json'
self.server.maxRecentPosts if not os.path.isfile(postFilename):
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:
self._404() self._404()
self.server.GETbusy = False self.server.GETbusy = False
return True 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, def _showInbox(self, authorized: bool,
callingDomain: str, path: str, callingDomain: str, path: str,