merge-requests/30/head
Bob Mottram 2021-05-04 11:17:06 +01:00
parent eeeec16297
commit 4b82938b7c
2 changed files with 46 additions and 21 deletions

View File

@ -822,7 +822,12 @@ class PubServer(BaseHTTPRequestHandler):
authorized: bool, authorized: bool,
httpPrefix: str, httpPrefix: str,
baseDir: str, nickname: str, domain: str, baseDir: str, nickname: str, domain: str,
domainFull: str) -> bool: domainFull: str,
onionDomain: str, i2pDomain: str,
translate: {},
registration: bool,
systemLanguage: str,
projectVersion: str) -> 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
@ -900,30 +905,37 @@ class PubServer(BaseHTTPRequestHandler):
sendJson = [] sendJson = []
sendJsonStr = 'masto API timelines sent' sendJsonStr = 'masto API timelines sent'
adminNickname = getConfigParam(self.server.baseDir, 'admin') adminNickname = getConfigParam(baseDir, 'admin')
if adminNickname and path == '/api/v1/instance': if adminNickname and path == '/api/v1/instance':
instanceDescriptionShort = \ instanceDescriptionShort = \
getConfigParam(self.server.baseDir, getConfigParam(baseDir,
'instanceDescriptionShort') 'instanceDescriptionShort')
if not instanceDescriptionShort: if not instanceDescriptionShort:
instanceDescriptionShort = \ instanceDescriptionShort = \
self.server.translate['Yet another Epicyon Instance'] translate['Yet another Epicyon Instance']
instanceDescription = getConfigParam(self.server.baseDir, instanceDescription = getConfigParam(baseDir,
'instanceDescription') 'instanceDescription')
instanceTitle = getConfigParam(self.server.baseDir, instanceTitle = getConfigParam(baseDir, 'instanceTitle')
'instanceTitle')
if callingDomain.endswith('.onion') and onionDomain:
domainFull = onionDomain
httpPrefix = 'http'
elif (callingDomain.endswith('.i2p') and i2pDomain):
domainFull = i2pDomain
httpPrefix = 'http'
sendJson = \ sendJson = \
metaDataInstance(instanceTitle, metaDataInstance(instanceTitle,
instanceDescriptionShort, instanceDescriptionShort,
instanceDescription, instanceDescription,
self.server.httpPrefix, httpPrefix,
self.server.baseDir, baseDir,
adminNickname, adminNickname,
self.server.domain, domain,
self.server.domainFull, domainFull,
self.server.registration, registration,
self.server.systemLanguage, systemLanguage,
self.server.projectVersion) projectVersion)
sendJsonStr = 'masto API instance metadata sent' sendJsonStr = 'masto API instance metadata sent'
elif path.startswith('/api/v1/instance/peers'): elif path.startswith('/api/v1/instance/peers'):
# This is just a dummy result. # This is just a dummy result.
@ -931,7 +943,7 @@ class PubServer(BaseHTTPRequestHandler):
# On a large instance you are somewhat lost in the crowd, but on # On a large instance you are somewhat lost in the crowd, but on
# small instances a full list of peers would convey a lot of # small instances a full list of peers would convey a lot of
# information about the interests of a small number of accounts # information about the interests of a small number of accounts
sendJson = ['mastodon.social', self.server.domainFull] sendJson = ['mastodon.social', domainFull]
sendJsonStr = 'masto API peers metadata sent' sendJsonStr = 'masto API peers metadata sent'
elif path.startswith('/api/v1/instance/activity'): elif path.startswith('/api/v1/instance/activity'):
sendJson = [] sendJson = []
@ -962,10 +974,17 @@ class PubServer(BaseHTTPRequestHandler):
def _mastoApi(self, path: str, callingDomain: str, def _mastoApi(self, path: str, callingDomain: str,
authorized: bool, httpPrefix: str, authorized: bool, httpPrefix: str,
baseDir: str, nickname: str, domain: str, baseDir: str, nickname: str, domain: str,
domainFull: str) -> bool: domainFull: str,
onionDomain: str, i2pDomain: str,
translate: {},
registration: bool,
systemLanguage: str,
projectVersion: str) -> bool:
return self._mastoApiV1(path, callingDomain, authorized, return self._mastoApiV1(path, callingDomain, authorized,
httpPrefix, baseDir, nickname, domain, httpPrefix, baseDir, nickname, domain,
domainFull) domainFull, onionDomain, i2pDomain,
translate, registration, systemLanguage,
projectVersion)
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'):
@ -10801,7 +10820,13 @@ class PubServer(BaseHTTPRequestHandler):
self.server.baseDir, self.server.baseDir,
self.authorizedNickname, self.authorizedNickname,
self.server.domain, self.server.domain,
self.server.domainFull): self.server.domainFull,
self.server.onionDomain,
self.server.i2pDomain,
self.server.translate,
self.server.registration,
self.server.systemLanguage,
self.server.projectVersion):
return return
self._benchmarkGETtimings(GETstartTime, GETtimings, self._benchmarkGETtimings(GETstartTime, GETtimings,

View File

@ -105,13 +105,13 @@ def metaDataInstance(instanceTitle: str,
'id': '1', 'id': '1',
'last_status_at': '2019-07-01T10:30:00Z', 'last_status_at': '2019-07-01T10:30:00Z',
'locked': adminActor['manuallyApprovesFollowers'], 'locked': adminActor['manuallyApprovesFollowers'],
'note': '<p>Admin of '+domain+'</p>', 'note': '<p>Admin of ' + domain + '</p>',
'statuses_count': 1, 'statuses_count': 1,
'url': url, 'url': url,
'username': adminActor['preferredUsername'] 'username': adminActor['preferredUsername']
}, },
'description': instanceDescription, 'description': instanceDescription,
'email': 'admin@'+domain, 'email': 'admin@' + domain,
'languages': [systemLanguage], 'languages': [systemLanguage],
'registrations': registration, 'registrations': registration,
'short_description': instanceDescriptionShort, 'short_description': instanceDescriptionShort,
@ -120,7 +120,7 @@ def metaDataInstance(instanceTitle: str,
'status_count': 1, 'status_count': 1,
'user_count': noOfAccounts(baseDir) 'user_count': noOfAccounts(baseDir)
}, },
'thumbnail': httpPrefix+'://'+domainFull+'/login.png', 'thumbnail': httpPrefix + '://' + domainFull + '/login.png',
'title': instanceTitle, 'title': instanceTitle,
'uri': domainFull, 'uri': domainFull,
'urls': {}, 'urls': {},