mirror of https://gitlab.com/bashrc2/epicyon
Anticipate future masto api versions
parent
b200fce1f8
commit
7422c4f860
23
daemon.py
23
daemon.py
|
@ -781,7 +781,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
return True
|
||||
return False
|
||||
|
||||
def _mastoApi(self, callingDomain: str) -> bool:
|
||||
def _mastoApiV1(self, callingDomain: str, authorized: bool) -> bool:
|
||||
"""This is a vestigil mastodon API for the purpose
|
||||
of returning an empty result to sites like
|
||||
https://mastopeek.app-dist.eu
|
||||
|
@ -789,7 +789,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if not self.path.startswith('/api/v1/'):
|
||||
return False
|
||||
if self.server.debug:
|
||||
print('DEBUG: mastodon api ' + self.path)
|
||||
print('DEBUG: mastodon api v1 ' + self.path)
|
||||
adminNickname = getConfigParam(self.server.baseDir, 'admin')
|
||||
if adminNickname and self.path == '/api/v1/instance':
|
||||
instanceDescriptionShort = \
|
||||
|
@ -871,6 +871,9 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self._404()
|
||||
return True
|
||||
|
||||
def _mastoApi(self, callingDomain: str, authorized: bool) -> bool:
|
||||
return self._mastoApiV1(callingDomain, authorized)
|
||||
|
||||
def _nodeinfo(self, callingDomain: str) -> bool:
|
||||
if not self.path.startswith('/nodeinfo/2.0'):
|
||||
return False
|
||||
|
@ -9796,14 +9799,6 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self._benchmarkGETtimings(GETstartTime, GETtimings,
|
||||
'start', '_nodeinfo[callingDomain]')
|
||||
|
||||
# minimal mastodon api
|
||||
if self._mastoApi(callingDomain):
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime, GETtimings,
|
||||
'_nodeinfo[callingDomain]',
|
||||
'_mastoApi[callingDomain]')
|
||||
|
||||
if self.path == '/logout':
|
||||
if not self.server.newsInstance:
|
||||
msg = \
|
||||
|
@ -9896,6 +9891,14 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self._benchmarkGETtimings(GETstartTime, GETtimings,
|
||||
'show logout', 'isAuthorized')
|
||||
|
||||
# minimal mastodon api
|
||||
if self._mastoApi(callingDomain, authorized):
|
||||
return
|
||||
|
||||
self._benchmarkGETtimings(GETstartTime, GETtimings,
|
||||
'_nodeinfo[callingDomain]',
|
||||
'_mastoApi[callingDomain]')
|
||||
|
||||
if not self.server.session:
|
||||
print('Starting new session during GET')
|
||||
self.server.session = createSession(self.server.proxyType)
|
||||
|
|
Loading…
Reference in New Issue