From 4489cf143aa04ed82ab54652d95b972d0662316b Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 22 Jan 2021 14:58:35 +0000 Subject: [PATCH] Stub implementation of masto api --- daemon.py | 42 +++++++++++++++++++++++++++++++++++++++++- mastoapiv1.py | 2 +- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/daemon.py b/daemon.py index def834e31..887b3845e 100644 --- a/daemon.py +++ b/daemon.py @@ -813,7 +813,12 @@ class PubServer(BaseHTTPRequestHandler): if mastoId is not None: pathNickname = getNicknameFromMastoApiV1Id(mastoId) if pathNickname: - if '/followers?' in path or '/following?' in path: + originalPath = path + if '/followers?' in path or \ + '/following?' in path or \ + '/search?' in path or \ + '/relationships?' in path or \ + '/statuses?' in path: path = path.split('?')[0] if path.endswith('/followers'): sendJson = [] @@ -821,11 +826,46 @@ class PubServer(BaseHTTPRequestHandler): elif path.endswith('/following'): sendJson = [] sendJsonStr = 'masto API following sent for ' + nickname + elif path.endswith('/statuses'): + sendJson = [] + sendJsonStr = 'masto API statuses sent for ' + nickname + elif path.endswith('/search'): + sendJson = [] + sendJsonStr = 'masto API search sent ' + originalPath + elif path.endswith('/relationships'): + sendJson = [] + sendJsonStr = \ + 'masto API relationships sent ' + originalPath else: sendJson = \ getMastoApiV1Account(baseDir, pathNickname, domain) sendJsonStr = 'masto API account sent for ' + nickname + if path.startswith('/api/v1/blocks'): + sendJson = [] + sendJsonStr = 'masto API instance blocks sent' + elif path.startswith('/api/v1/favorites'): + sendJson = [] + sendJsonStr = 'masto API favorites sent' + elif path.startswith('/api/v1/follow_requests'): + sendJson = [] + sendJsonStr = 'masto API follow requests sent' + elif path.startswith('/api/v1/mutes'): + sendJson = [] + sendJsonStr = 'masto API mutes sent' + elif path.startswith('/api/v1/notifications'): + sendJson = [] + sendJsonStr = 'masto API notifications sent' + elif path.startswith('/api/v1/reports'): + sendJson = [] + sendJsonStr = 'masto API reports sent' + elif path.startswith('/api/v1/statuses'): + sendJson = [] + sendJsonStr = 'masto API statuses sent' + elif path.startswith('/api/v1/timelines'): + sendJson = [] + sendJsonStr = 'masto API timelines sent' + adminNickname = getConfigParam(self.server.baseDir, 'admin') if adminNickname and path == '/api/v1/instance': instanceDescriptionShort = \ diff --git a/mastoapiv1.py b/mastoapiv1.py index 40ba8cd2a..dd2ff9ffc 100644 --- a/mastoapiv1.py +++ b/mastoapiv1.py @@ -64,7 +64,7 @@ def getMastoApiV1Account(baseDir: str, nickname: str, domain: str) -> {}: "acct": nickname, "display_name": accountJson['name'], "locked": accountJson['manuallyApprovesFollowers'], - "created_at": "", + "created_at": "2016-10-05T10:30:00Z", "followers_count": 0, "following_count": 0, "statuses_count": 0,