fix: check email last

pull/32/head
db0 2023-09-23 23:16:03 +02:00
parent 8565ead721
commit 62c0f62aa0
1 changed files with 4 additions and 4 deletions

View File

@ -101,16 +101,16 @@ def discover_admins(domain,software):
try: try:
site = requests.get(f"https://{domain}/api/v1/instance") site = requests.get(f"https://{domain}/api/v1/instance")
site_json = site.json() site_json = site.json()
# Pleroma/Akkoma style
if "email" in site_json:
admin_username = site_json["email"].split('@',1)[0]
return [admin_username]
# Misskey/Firefish style # Misskey/Firefish style
if "contact_account" in site_json: if "contact_account" in site_json:
return [site_json["contact_account"]["username"]] return [site_json["contact_account"]["username"]]
# Mastodon style # Mastodon style
if "contact" in site_json: if "contact" in site_json:
return [site_json["contact"]["account"]["username"]] return [site_json["contact"]["account"]["username"]]
# Pleroma/Akkoma style
if "email" in site_json:
admin_username = site_json["email"].split('@',1)[0]
return [admin_username]
raise Exception(f"Site software '{software} does not match any of the known APIs") raise Exception(f"Site software '{software} does not match any of the known APIs")
except Exception as err: except Exception as err:
logger.error(f"Error retrieving {software} site info for {domain}: {err}") logger.error(f"Error retrieving {software} site info for {domain}: {err}")