1
0
mirror of https://github.com/ihabunek/toot.git synced 2024-06-09 06:10:43 +00:00

Change api.create_app to take an url

This commit is contained in:
Ivan Habunek 2022-11-26 18:45:20 +01:00
parent 1801f04b6a
commit 68bf18213b
No known key found for this signature in database
GPG Key ID: F5F0623FF5EBCB3D
4 changed files with 10 additions and 9 deletions

View File

@ -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,

View File

@ -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):

View File

@ -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,

View File

@ -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.")