mirror of https://gitlab.com/bashrc2/epicyon
Move shares feed to its own method
parent
7bb1214813
commit
06a6c93131
178
daemon.py
178
daemon.py
|
@ -6298,6 +6298,90 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.GETbusy = False
|
||||
return True
|
||||
|
||||
def _showSharesFeed(self, authorized: bool,
|
||||
callingDomain: str, path: str,
|
||||
baseDir: str, httpPrefix: str,
|
||||
domain: str, domainFull: str, port: int,
|
||||
onionDomain: str, i2pDomain: str,
|
||||
GETstartTime, GETtimings: {},
|
||||
proxyType: str, cookie: str,
|
||||
debug: str) -> bool:
|
||||
"""Shows the shares feed
|
||||
"""
|
||||
shares = \
|
||||
getSharesFeedForPerson(baseDir, domain, port, path,
|
||||
httpPrefix, sharesPerPage)
|
||||
if shares:
|
||||
if self._requestHTTP():
|
||||
pageNumber = 1
|
||||
if '?page=' not in path:
|
||||
searchPath = path
|
||||
# get a page of shares, not the summary
|
||||
shares = \
|
||||
getSharesFeedForPerson(baseDir, domain, port,
|
||||
path + '?page=true',
|
||||
httpPrefix,
|
||||
sharesPerPage)
|
||||
else:
|
||||
pageNumberStr = path.split('?page=')[1]
|
||||
if '#' in pageNumberStr:
|
||||
pageNumberStr = pageNumberStr.split('#')[0]
|
||||
if pageNumberStr.isdigit():
|
||||
pageNumber = int(pageNumberStr)
|
||||
searchPath = path.split('?page=')[0]
|
||||
getPerson = \
|
||||
personLookup(domain,
|
||||
searchPath.replace('/shares', ''),
|
||||
baseDir)
|
||||
if getPerson:
|
||||
if not self.server.session:
|
||||
print('Starting new session during profile')
|
||||
self.server.session = createSession(proxyType)
|
||||
if not self.server.session:
|
||||
print('ERROR: GET failed to create session ' +
|
||||
'during profile')
|
||||
self._404()
|
||||
self.server.GETbusy = False
|
||||
return True
|
||||
msg = \
|
||||
htmlProfile(self.server.defaultTimeline,
|
||||
self.server.recentPostsCache,
|
||||
self.server.maxRecentPosts,
|
||||
self.server.translate,
|
||||
self.server.projectVersion,
|
||||
baseDir, httpPrefix,
|
||||
authorized,
|
||||
self.server.ocapAlways,
|
||||
getPerson, 'shares',
|
||||
self.server.session,
|
||||
self.server.cachedWebfingers,
|
||||
self.server.personCache,
|
||||
self.server.YTReplacementDomain,
|
||||
shares,
|
||||
pageNumber, sharesPerPage)
|
||||
msg = msg.encode('utf-8')
|
||||
self._set_headers('text/html', len(msg),
|
||||
cookie, callingDomain)
|
||||
self._write(msg)
|
||||
self._benchmarkGETtimings(GETstartTime, GETtimings,
|
||||
'show moderation done',
|
||||
'show profile 2')
|
||||
self.server.GETbusy = False
|
||||
return True
|
||||
else:
|
||||
if self._fetchAuthenticated():
|
||||
msg = json.dumps(shares,
|
||||
ensure_ascii=False)
|
||||
msg = msg.encode('utf-8')
|
||||
self._set_headers('application/json', len(msg),
|
||||
None, callingDomain)
|
||||
self._write(msg)
|
||||
else:
|
||||
self._404()
|
||||
self.server.GETbusy = False
|
||||
return True
|
||||
return False
|
||||
|
||||
def do_GET(self):
|
||||
callingDomain = self.server.domainFull
|
||||
if self.headers.get('Host'):
|
||||
|
@ -8281,87 +8365,19 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
'show outbox done',
|
||||
'show moderation done')
|
||||
|
||||
shares = \
|
||||
getSharesFeedForPerson(self.server.baseDir,
|
||||
self.server.domain,
|
||||
self.server.port, self.path,
|
||||
self.server.httpPrefix,
|
||||
sharesPerPage)
|
||||
if shares:
|
||||
if self._requestHTTP():
|
||||
pageNumber = 1
|
||||
if '?page=' not in self.path:
|
||||
searchPath = self.path
|
||||
# get a page of shares, not the summary
|
||||
shares = \
|
||||
getSharesFeedForPerson(self.server.baseDir,
|
||||
self.server.domain,
|
||||
self.server.port,
|
||||
self.path + '?page=true',
|
||||
self.server.httpPrefix,
|
||||
sharesPerPage)
|
||||
else:
|
||||
pageNumberStr = self.path.split('?page=')[1]
|
||||
if '#' in pageNumberStr:
|
||||
pageNumberStr = pageNumberStr.split('#')[0]
|
||||
if pageNumberStr.isdigit():
|
||||
pageNumber = int(pageNumberStr)
|
||||
searchPath = self.path.split('?page=')[0]
|
||||
getPerson = \
|
||||
personLookup(self.server.domain,
|
||||
searchPath.replace('/shares', ''),
|
||||
self.server.baseDir)
|
||||
if getPerson:
|
||||
if not self.server.session:
|
||||
print('Starting new session during profile')
|
||||
self.server.session = \
|
||||
createSession(self.server.proxyType)
|
||||
if not self.server.session:
|
||||
print('ERROR: GET failed to create session ' +
|
||||
'during profile')
|
||||
self._404()
|
||||
self.server.GETbusy = False
|
||||
return
|
||||
msg = \
|
||||
htmlProfile(self.server.defaultTimeline,
|
||||
self.server.recentPostsCache,
|
||||
self.server.maxRecentPosts,
|
||||
self.server.translate,
|
||||
self.server.projectVersion,
|
||||
self.server.baseDir,
|
||||
self.server.httpPrefix,
|
||||
authorized,
|
||||
self.server.ocapAlways,
|
||||
getPerson, 'shares',
|
||||
self.server.session,
|
||||
self.server.cachedWebfingers,
|
||||
self.server.personCache,
|
||||
self.server.YTReplacementDomain,
|
||||
shares,
|
||||
pageNumber, sharesPerPage)
|
||||
msg = msg.encode('utf-8')
|
||||
self._set_headers('text/html',
|
||||
len(msg),
|
||||
cookie, callingDomain)
|
||||
self._write(msg)
|
||||
self._benchmarkGETtimings(GETstartTime, GETtimings,
|
||||
'show moderation done',
|
||||
'show profile 2')
|
||||
self.server.GETbusy = False
|
||||
return
|
||||
else:
|
||||
if self._fetchAuthenticated():
|
||||
msg = json.dumps(shares,
|
||||
ensure_ascii=False)
|
||||
msg = msg.encode('utf-8')
|
||||
self._set_headers('application/json',
|
||||
len(msg),
|
||||
None, callingDomain)
|
||||
self._write(msg)
|
||||
else:
|
||||
self._404()
|
||||
self.server.GETbusy = False
|
||||
return
|
||||
if self._showSharesFeed(authorized,
|
||||
callingDomain, self.path,
|
||||
self.server.baseDir,
|
||||
self.server.httpPrefix,
|
||||
self.server.domain,
|
||||
self.server.domainFull,
|
||||
self.server.port,
|
||||
self.server.onionDomain,
|
||||
self.server.i2pDomain,
|
||||
GETstartTime, GETtimings,
|
||||
self.server.proxyType,
|
||||
cookie, self.server.debug):
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime, GETtimings,
|
||||
'show moderation done',
|
||||
|
|
Loading…
Reference in New Issue