mirror of
https://github.com/ihabunek/toot.git
synced 2024-09-22 04:25:55 -04:00
Change api.create_app to take an url
This commit is contained in:
parent
1801f04b6a
commit
68bf18213b
@ -15,7 +15,7 @@ def test_create_app(mock_post):
|
||||
'client_secret': 'bar',
|
||||
})
|
||||
|
||||
create_app('bigfish.software')
|
||||
create_app('https://bigfish.software')
|
||||
|
||||
mock_post.assert_called_once_with('https://bigfish.software/api/v1/apps', json={
|
||||
'website': CLIENT_WEBSITE,
|
||||
|
@ -43,8 +43,9 @@ if not HOSTNAME or not DATABASE_DSN:
|
||||
|
||||
|
||||
def create_app():
|
||||
response = api.create_app(HOSTNAME, scheme="http")
|
||||
return App(HOSTNAME, f"http://{HOSTNAME}", response["client_id"], response["client_secret"])
|
||||
base_url = f"http://{HOSTNAME}"
|
||||
response = api.create_app(base_url)
|
||||
return App(HOSTNAME, base_url, response["client_id"], response["client_secret"])
|
||||
|
||||
|
||||
def register_account(app: App):
|
||||
|
@ -24,8 +24,8 @@ def _status_action(app, user, status_id, action):
|
||||
return http.post(app, user, url).json()
|
||||
|
||||
|
||||
def create_app(domain, scheme='https'):
|
||||
url = '{}://{}/api/v1/apps'.format(scheme, domain)
|
||||
def create_app(base_url):
|
||||
url = f"{base_url}/api/v1/apps"
|
||||
|
||||
json = {
|
||||
'client_name': CLIENT_NAME,
|
||||
|
@ -18,15 +18,15 @@ def register_app(domain, scheme='https'):
|
||||
print_out("Found instance <blue>{}</blue> running Mastodon version <yellow>{}</yellow>".format(
|
||||
instance['title'], instance['version']))
|
||||
|
||||
base_url = f"{scheme}://{domain}"
|
||||
|
||||
try:
|
||||
print_out("Registering application...")
|
||||
response = api.create_app(domain, scheme)
|
||||
response = api.create_app(base_url)
|
||||
except ApiError:
|
||||
raise ConsoleError("Registration failed.")
|
||||
|
||||
base_url = scheme + '://' + domain
|
||||
|
||||
app = App(domain, base_url, response['client_id'], response['client_secret'])
|
||||
app = App(domain, base_url, response["client_id"], response["client_secret"])
|
||||
config.save_app(app)
|
||||
|
||||
print_out("Application tokens saved.")
|
||||
|
Loading…
Reference in New Issue
Block a user