From 9e81ad9bad12c7186d1a6b4ee355beaef1aba9ba Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 24 Oct 2021 10:02:28 +0100 Subject: [PATCH] More information about calling domain --- mastoapiv1.py | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/mastoapiv1.py b/mastoapiv1.py index b00490934..9661b31d5 100644 --- a/mastoapiv1.py +++ b/mastoapiv1.py @@ -111,6 +111,9 @@ def mastoApiV1Response(path: str, callingDomain: str, sendJsonStr = \ '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 mastoId = _getMastApiV1Id(path) if mastoId is not None: @@ -127,33 +130,33 @@ def mastoApiV1Response(path: str, callingDomain: str, sendJson = [] sendJsonStr = \ 'masto API followers sent for ' + nickname + \ - ' ' + uaStr + callingInfo elif path.endswith('/following'): sendJson = [] sendJsonStr = \ 'masto API following sent for ' + nickname + \ - ' ' + uaStr + callingInfo elif path.endswith('/statuses'): sendJson = [] sendJsonStr = \ 'masto API statuses sent for ' + nickname + \ - ' ' + uaStr + callingInfo elif path.endswith('/search'): sendJson = [] sendJsonStr = \ 'masto API search sent ' + originalPath + \ - ' ' + uaStr + callingInfo elif path.endswith('/relationships'): sendJson = [] sendJsonStr = \ 'masto API relationships sent ' + originalPath + \ - ' ' + uaStr + callingInfo else: sendJson = \ _getMastoApiV1Account(baseDir, pathNickname, domain) sendJsonStr = \ 'masto API account sent for ' + nickname + \ - ' ' + uaStr + callingInfo # NOTE: adding support for '/api/v1/directory seems to create # federation problems, so avoid implementing that @@ -161,37 +164,37 @@ def mastoApiV1Response(path: str, callingDomain: str, if path.startswith('/api/v1/blocks'): sendJson = [] sendJsonStr = \ - 'masto API instance blocks sent ' + path + ' ' + uaStr + 'masto API instance blocks sent ' + path + callingInfo elif path.startswith('/api/v1/favorites'): sendJson = [] - sendJsonStr = 'masto API favorites sent ' + path + ' ' + uaStr + sendJsonStr = 'masto API favorites sent ' + path + callingInfo elif path.startswith('/api/v1/follow_requests'): sendJson = [] sendJsonStr = \ - 'masto API follow requests sent ' + path + ' ' + uaStr + 'masto API follow requests sent ' + path + callingInfo elif path.startswith('/api/v1/mutes'): sendJson = [] sendJsonStr = \ - 'masto API mutes sent ' + path + ' ' + uaStr + 'masto API mutes sent ' + path + callingInfo elif path.startswith('/api/v1/notifications'): sendJson = [] sendJsonStr = \ - 'masto API notifications sent ' + path + ' ' + uaStr + 'masto API notifications sent ' + path + callingInfo elif path.startswith('/api/v1/reports'): sendJson = [] - sendJsonStr = 'masto API reports sent ' + path + ' ' + uaStr + sendJsonStr = 'masto API reports sent ' + path + callingInfo elif path.startswith('/api/v1/statuses'): sendJson = [] - sendJsonStr = 'masto API statuses sent ' + path + ' ' + uaStr + sendJsonStr = 'masto API statuses sent ' + path + callingInfo elif path.startswith('/api/v1/timelines'): sendJson = { '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'): sendJson = customEmoji sendJsonStr = \ - 'masto API custom emojis sent ' + path + ' ' + uaStr + 'masto API custom emojis sent ' + path + callingInfo adminNickname = getConfigParam(baseDir, 'admin') if adminNickname and path == '/api/v1/instance':