kopia lustrzana https://github.com/ihabunek/toot
Make get_instance return the response instead of json
rodzic
3f680312c6
commit
9664d71b57
|
@ -41,7 +41,7 @@ ASSETS_DIR = str(Path(__file__).parent.parent / "assets")
|
||||||
|
|
||||||
|
|
||||||
def create_app(base_url):
|
def create_app(base_url):
|
||||||
instance = api.get_instance(base_url)
|
instance = api.get_instance(base_url).json()
|
||||||
response = api.create_app(base_url)
|
response = api.create_app(base_url)
|
||||||
return App(instance["uri"], base_url, response["client_id"], response["client_secret"])
|
return App(instance["uri"], base_url, response["client_id"], response["client_secret"])
|
||||||
|
|
||||||
|
|
|
@ -558,9 +558,9 @@ def clear_notifications(app, user):
|
||||||
http.post(app, user, '/api/v1/notifications/clear')
|
http.post(app, user, '/api/v1/notifications/clear')
|
||||||
|
|
||||||
|
|
||||||
def get_instance(base_url):
|
def get_instance(base_url: str) -> Response:
|
||||||
url = f"{base_url}/api/v1/instance"
|
url = f"{base_url}/api/v1/instance"
|
||||||
return http.anon_get(url).json()
|
return http.anon_get(url)
|
||||||
|
|
||||||
|
|
||||||
def get_lists(app, user):
|
def get_lists(app, user):
|
||||||
|
|
|
@ -542,7 +542,7 @@ def instance(app, user, args):
|
||||||
raise ConsoleError("Please specify an instance.")
|
raise ConsoleError("Please specify an instance.")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
instance = api.get_instance(base_url)
|
instance = api.get_instance(base_url).json()
|
||||||
instance = from_dict(Instance, instance)
|
instance = from_dict(Instance, instance)
|
||||||
print_instance(instance)
|
print_instance(instance)
|
||||||
except ApiError:
|
except ApiError:
|
||||||
|
|
|
@ -306,7 +306,7 @@ class TUI(urwid.Frame):
|
||||||
See: https://github.com/mastodon/mastodon/issues/19328
|
See: https://github.com/mastodon/mastodon/issues/19328
|
||||||
"""
|
"""
|
||||||
def _load_instance():
|
def _load_instance():
|
||||||
return api.get_instance(self.app.base_url)
|
return api.get_instance(self.app.base_url).json()
|
||||||
|
|
||||||
def _done(instance):
|
def _done(instance):
|
||||||
self.max_toot_chars = get_max_toot_chars(instance, DEFAULT_MAX_TOOT_CHARS)
|
self.max_toot_chars = get_max_toot_chars(instance, DEFAULT_MAX_TOOT_CHARS)
|
||||||
|
|
Ładowanie…
Reference in New Issue