mirror of
https://github.com/ihabunek/toot.git
synced 2024-09-29 04:35:54 -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',
|
'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={
|
mock_post.assert_called_once_with('https://bigfish.software/api/v1/apps', json={
|
||||||
'website': CLIENT_WEBSITE,
|
'website': CLIENT_WEBSITE,
|
||||||
|
@ -43,8 +43,9 @@ if not HOSTNAME or not DATABASE_DSN:
|
|||||||
|
|
||||||
|
|
||||||
def create_app():
|
def create_app():
|
||||||
response = api.create_app(HOSTNAME, scheme="http")
|
base_url = f"http://{HOSTNAME}"
|
||||||
return App(HOSTNAME, f"http://{HOSTNAME}", response["client_id"], response["client_secret"])
|
response = api.create_app(base_url)
|
||||||
|
return App(HOSTNAME, base_url, response["client_id"], response["client_secret"])
|
||||||
|
|
||||||
|
|
||||||
def register_account(app: App):
|
def register_account(app: App):
|
||||||
|
@ -24,8 +24,8 @@ def _status_action(app, user, status_id, action):
|
|||||||
return http.post(app, user, url).json()
|
return http.post(app, user, url).json()
|
||||||
|
|
||||||
|
|
||||||
def create_app(domain, scheme='https'):
|
def create_app(base_url):
|
||||||
url = '{}://{}/api/v1/apps'.format(scheme, domain)
|
url = f"{base_url}/api/v1/apps"
|
||||||
|
|
||||||
json = {
|
json = {
|
||||||
'client_name': CLIENT_NAME,
|
'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(
|
print_out("Found instance <blue>{}</blue> running Mastodon version <yellow>{}</yellow>".format(
|
||||||
instance['title'], instance['version']))
|
instance['title'], instance['version']))
|
||||||
|
|
||||||
|
base_url = f"{scheme}://{domain}"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
print_out("Registering application...")
|
print_out("Registering application...")
|
||||||
response = api.create_app(domain, scheme)
|
response = api.create_app(base_url)
|
||||||
except ApiError:
|
except ApiError:
|
||||||
raise ConsoleError("Registration failed.")
|
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)
|
config.save_app(app)
|
||||||
|
|
||||||
print_out("Application tokens saved.")
|
print_out("Application tokens saved.")
|
||||||
|
Loading…
Reference in New Issue
Block a user