From e42c4c3b801c223ca9c102deff0a1733c30f92ea Mon Sep 17 00:00:00 2001 From: Balazs Nadasdi Date: Mon, 21 Jan 2019 17:25:20 +0100 Subject: [PATCH] use http.get instead of hacking _status_action in api.py (and fix a typo) --- toot/api.py | 24 ++++++++++++------------ toot/console.py | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/toot/api.py b/toot/api.py index e302f84..e30ac04 100644 --- a/toot/api.py +++ b/toot/api.py @@ -17,17 +17,10 @@ def _account_action(app, user, account, action): return http.post(app, user, url).json() -def _status_action(app, user, status_id, action, method='post'): - if action is None: - url = '/api/v1/statuses/{}'.format(status_id) - method = 'get' - else: - url = '/api/v1/statuses/{}/{}'.format(status_id, action) +def _status_action(app, user, status_id, action): + url = '/api/v1/statuses/{}/{}'.format(status_id, action) - if method == 'post': - return http.post(app, user, url).json() - elif method == 'get': - return http.get(app, user, url).json() + return http.post(app, user, url).json() def create_app(domain, scheme='https'): @@ -150,8 +143,12 @@ def pin(app, user, status_id): def unpin(app, user, status_id): return _status_action(app, user, status_id, 'unpin') + def context(app, user, status_id): - return _status_action(app, user, status_id, 'context', method='get') + url = '/api/v1/statuses/{}/context'.format(status_id) + + return http.get(app, user, url).json() + def timeline_home(app, user): return http.get(app, user, '/api/v1/timelines/home').json() @@ -255,7 +252,10 @@ def verify_credentials(app, user): def single_status(app, user, status_id): - return _status_action(app, user, status_id, None, method='get') + url = '/api/v1/statuses/{}'.format(status_id) + + return http.get(app, user, url).json() + def get_notifications(app, user): return http.get(app, user, '/api/v1/notifications').json() diff --git a/toot/console.py b/toot/console.py index 5b45eff..d541a63 100644 --- a/toot/console.py +++ b/toot/console.py @@ -156,7 +156,7 @@ READ_COMMANDS = [ ), Command( name="thread", - description="Show toot thfread items", + description="Show toot thread items", arguments=[ (["status_id"], { "help": "Show thread for toot.",