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