More information about calling domain

main
Bob Mottram 2021-10-24 10:02:28 +01:00
parent 19194f3d30
commit 9e81ad9bad
1 changed files with 18 additions and 15 deletions

View File

@ -111,6 +111,9 @@ def mastoApiV1Response(path: str, callingDomain: str,
sendJsonStr = \ sendJsonStr = \
'masto API account sent for ' + nickname + ' ' + uaStr 'masto API account sent for ' + nickname + ' ' + uaStr
# information about where the request is coming from
callingInfo = ' ' + uaStr + ', ' + callingDomain
# Parts of the api which don't need authorization # Parts of the api which don't need authorization
mastoId = _getMastApiV1Id(path) mastoId = _getMastApiV1Id(path)
if mastoId is not None: if mastoId is not None:
@ -127,33 +130,33 @@ def mastoApiV1Response(path: str, callingDomain: str,
sendJson = [] sendJson = []
sendJsonStr = \ sendJsonStr = \
'masto API followers sent for ' + nickname + \ 'masto API followers sent for ' + nickname + \
' ' + uaStr callingInfo
elif path.endswith('/following'): elif path.endswith('/following'):
sendJson = [] sendJson = []
sendJsonStr = \ sendJsonStr = \
'masto API following sent for ' + nickname + \ 'masto API following sent for ' + nickname + \
' ' + uaStr callingInfo
elif path.endswith('/statuses'): elif path.endswith('/statuses'):
sendJson = [] sendJson = []
sendJsonStr = \ sendJsonStr = \
'masto API statuses sent for ' + nickname + \ 'masto API statuses sent for ' + nickname + \
' ' + uaStr callingInfo
elif path.endswith('/search'): elif path.endswith('/search'):
sendJson = [] sendJson = []
sendJsonStr = \ sendJsonStr = \
'masto API search sent ' + originalPath + \ 'masto API search sent ' + originalPath + \
' ' + uaStr callingInfo
elif path.endswith('/relationships'): elif path.endswith('/relationships'):
sendJson = [] sendJson = []
sendJsonStr = \ sendJsonStr = \
'masto API relationships sent ' + originalPath + \ 'masto API relationships sent ' + originalPath + \
' ' + uaStr callingInfo
else: else:
sendJson = \ sendJson = \
_getMastoApiV1Account(baseDir, pathNickname, domain) _getMastoApiV1Account(baseDir, pathNickname, domain)
sendJsonStr = \ sendJsonStr = \
'masto API account sent for ' + nickname + \ 'masto API account sent for ' + nickname + \
' ' + uaStr callingInfo
# NOTE: adding support for '/api/v1/directory seems to create # NOTE: adding support for '/api/v1/directory seems to create
# federation problems, so avoid implementing that # federation problems, so avoid implementing that
@ -161,37 +164,37 @@ def mastoApiV1Response(path: str, callingDomain: str,
if path.startswith('/api/v1/blocks'): if path.startswith('/api/v1/blocks'):
sendJson = [] sendJson = []
sendJsonStr = \ sendJsonStr = \
'masto API instance blocks sent ' + path + ' ' + uaStr 'masto API instance blocks sent ' + path + callingInfo
elif path.startswith('/api/v1/favorites'): elif path.startswith('/api/v1/favorites'):
sendJson = [] sendJson = []
sendJsonStr = 'masto API favorites sent ' + path + ' ' + uaStr sendJsonStr = 'masto API favorites sent ' + path + callingInfo
elif path.startswith('/api/v1/follow_requests'): elif path.startswith('/api/v1/follow_requests'):
sendJson = [] sendJson = []
sendJsonStr = \ sendJsonStr = \
'masto API follow requests sent ' + path + ' ' + uaStr 'masto API follow requests sent ' + path + callingInfo
elif path.startswith('/api/v1/mutes'): elif path.startswith('/api/v1/mutes'):
sendJson = [] sendJson = []
sendJsonStr = \ sendJsonStr = \
'masto API mutes sent ' + path + ' ' + uaStr 'masto API mutes sent ' + path + callingInfo
elif path.startswith('/api/v1/notifications'): elif path.startswith('/api/v1/notifications'):
sendJson = [] sendJson = []
sendJsonStr = \ sendJsonStr = \
'masto API notifications sent ' + path + ' ' + uaStr 'masto API notifications sent ' + path + callingInfo
elif path.startswith('/api/v1/reports'): elif path.startswith('/api/v1/reports'):
sendJson = [] sendJson = []
sendJsonStr = 'masto API reports sent ' + path + ' ' + uaStr sendJsonStr = 'masto API reports sent ' + path + callingInfo
elif path.startswith('/api/v1/statuses'): elif path.startswith('/api/v1/statuses'):
sendJson = [] sendJson = []
sendJsonStr = 'masto API statuses sent ' + path + ' ' + uaStr sendJsonStr = 'masto API statuses sent ' + path + callingInfo
elif path.startswith('/api/v1/timelines'): elif path.startswith('/api/v1/timelines'):
sendJson = { sendJson = {
'error': 'This method requires an authenticated user' 'error': 'This method requires an authenticated user'
} }
sendJsonStr = 'masto API timelines sent ' + path + ' ' + uaStr sendJsonStr = 'masto API timelines sent ' + path + callingInfo
elif path.startswith('/api/v1/custom_emojis'): elif path.startswith('/api/v1/custom_emojis'):
sendJson = customEmoji sendJson = customEmoji
sendJsonStr = \ sendJsonStr = \
'masto API custom emojis sent ' + path + ' ' + uaStr 'masto API custom emojis sent ' + path + callingInfo
adminNickname = getConfigParam(baseDir, 'admin') adminNickname = getConfigParam(baseDir, 'admin')
if adminNickname and path == '/api/v1/instance': if adminNickname and path == '/api/v1/instance':