1
0
mirror of https://github.com/ihabunek/toot synced 2024-12-23 07:27:12 +01:00

Enable fetching instance info over http

issue #56
This commit is contained in:
Ivan Habunek 2018-12-30 09:53:12 +01:00
parent f7f867f1b3
commit b06e9ea733
No known key found for this signature in database
GPG Key ID: CDBD63C43A30BB95
4 changed files with 5 additions and 5 deletions

View File

@ -219,6 +219,6 @@ def get_notifications(app, user):
return http.get(app, user, '/api/v1/notifications').json() return http.get(app, user, '/api/v1/notifications').json()
def get_instance(domain): def get_instance(domain, scheme="https"):
url = "http://{}/api/v1/instance".format(domain) url = "{}://{}/api/v1/instance".format(scheme, domain)
return http.anon_get(url).json() return http.anon_get(url).json()

View File

@ -12,7 +12,7 @@ from toot.output import print_out
def register_app(domain, scheme='https'): def register_app(domain, scheme='https'):
print_out("Looking up instance info...") print_out("Looking up instance info...")
instance = api.get_instance(domain) instance = api.get_instance(domain, scheme)
print_out("Found instance <blue>{}</blue> running Mastodon version <yellow>{}</yellow>".format( print_out("Found instance <blue>{}</blue> running Mastodon version <yellow>{}</yellow>".format(
instance['title'], instance['version'])) instance['title'], instance['version']))

View File

@ -219,7 +219,7 @@ def instance(app, user, args):
assert_domain_exists(name) assert_domain_exists(name)
try: try:
instance = api.get_instance(name) instance = api.get_instance(name, args.scheme)
print_instance(instance) print_instance(instance)
except NotFoundError: except NotFoundError:
raise ConsoleError( raise ConsoleError(

View File

@ -131,7 +131,7 @@ READ_COMMANDS = [
"help": "instance domain (e.g. 'mastodon.social') or blank to use current", "help": "instance domain (e.g. 'mastodon.social') or blank to use current",
"nargs": "?", "nargs": "?",
}), }),
scheme_arg,
], ],
require_auth=False, require_auth=False,
), ),