mirror of
https://github.com/ihabunek/toot
synced 2025-01-11 09:03:57 +01:00
use http.get instead of hacking _status_action in api.py
(and fix a typo)
This commit is contained in:
parent
ee417df60e
commit
e42c4c3b80
24
toot/api.py
24
toot/api.py
@ -17,17 +17,10 @@ def _account_action(app, user, account, action):
|
|||||||
return http.post(app, user, url).json()
|
return http.post(app, user, url).json()
|
||||||
|
|
||||||
|
|
||||||
def _status_action(app, user, status_id, action, method='post'):
|
def _status_action(app, user, status_id, action):
|
||||||
if action is None:
|
url = '/api/v1/statuses/{}/{}'.format(status_id, action)
|
||||||
url = '/api/v1/statuses/{}'.format(status_id)
|
|
||||||
method = 'get'
|
|
||||||
else:
|
|
||||||
url = '/api/v1/statuses/{}/{}'.format(status_id, action)
|
|
||||||
|
|
||||||
if method == 'post':
|
return http.post(app, user, url).json()
|
||||||
return http.post(app, user, url).json()
|
|
||||||
elif method == 'get':
|
|
||||||
return http.get(app, user, url).json()
|
|
||||||
|
|
||||||
|
|
||||||
def create_app(domain, scheme='https'):
|
def create_app(domain, scheme='https'):
|
||||||
@ -150,8 +143,12 @@ def pin(app, user, status_id):
|
|||||||
def unpin(app, user, status_id):
|
def unpin(app, user, status_id):
|
||||||
return _status_action(app, user, status_id, 'unpin')
|
return _status_action(app, user, status_id, 'unpin')
|
||||||
|
|
||||||
|
|
||||||
def context(app, user, status_id):
|
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):
|
def timeline_home(app, user):
|
||||||
return http.get(app, user, '/api/v1/timelines/home').json()
|
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):
|
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):
|
def get_notifications(app, user):
|
||||||
return http.get(app, user, '/api/v1/notifications').json()
|
return http.get(app, user, '/api/v1/notifications').json()
|
||||||
|
@ -156,7 +156,7 @@ READ_COMMANDS = [
|
|||||||
),
|
),
|
||||||
Command(
|
Command(
|
||||||
name="thread",
|
name="thread",
|
||||||
description="Show toot thfread items",
|
description="Show toot thread items",
|
||||||
arguments=[
|
arguments=[
|
||||||
(["status_id"], {
|
(["status_id"], {
|
||||||
"help": "Show thread for toot.",
|
"help": "Show thread for toot.",
|
||||||
|
Loading…
Reference in New Issue
Block a user