fix: mastodon admin pull
parent
1b8cfe08b1
commit
a10524a35d
|
@ -88,7 +88,7 @@ def ensure_instance_registered(domain):
|
|||
admin_usernames = get_admin_for_software(software, domain)
|
||||
instance = database.find_instance_by_domain(domain)
|
||||
if instance:
|
||||
return instance, nodeinfo, site, admin_usernames
|
||||
return instance, nodeinfo, admin_usernames
|
||||
new_instance = Instance(
|
||||
domain=domain,
|
||||
open_registrations=open_registrations,
|
||||
|
@ -96,4 +96,4 @@ def ensure_instance_registered(domain):
|
|||
software=software,
|
||||
)
|
||||
new_instance.create()
|
||||
return new_instance, nodeinfo, site, admin_usernames
|
||||
return new_instance, nodeinfo, admin_usernames
|
||||
|
|
|
@ -81,7 +81,7 @@ class Endorsements(Resource):
|
|||
unbroken_chain, chainbreaker = database.has_unbroken_chain(instance.id)
|
||||
if not unbroken_chain:
|
||||
raise e.Forbidden(f"Guarantee chain for this instance has been broken. Chain ends at {chainbreaker.domain}!")
|
||||
target_instance, nodeinfo, site, admin_usernames = ensure_instance_registered(domain)
|
||||
target_instance, nodeinfo, admin_usernames = ensure_instance_registered(domain)
|
||||
if not target_instance:
|
||||
raise e.NotFound(f"Something went wrong trying to register this instance.")
|
||||
if len(target_instance.guarantors) == 0:
|
||||
|
|
|
@ -84,7 +84,7 @@ class Guarantees(Resource):
|
|||
unbroken_chain, chainbreaker = database.has_unbroken_chain(instance.id)
|
||||
if not unbroken_chain:
|
||||
raise e.Forbidden(f"Guarantee chain for this instance has been broken. Chain ends at {chainbreaker.domain}!")
|
||||
target_instance, nodeinfo, site, admin_usernames = ensure_instance_registered(domain)
|
||||
target_instance, nodeinfo, admin_usernames = ensure_instance_registered(domain)
|
||||
if not target_instance:
|
||||
raise e.NotFound(f"Something went wrong trying to register this instance.")
|
||||
if database.get_guarantee(target_instance.id,instance.id):
|
||||
|
|
|
@ -39,7 +39,7 @@ class WhitelistDomain(Resource):
|
|||
'''Display info about a specific instance
|
||||
'''
|
||||
self.args = self.get_parser.parse_args()
|
||||
instance, nodeinfo, site, admin_usernames = ensure_instance_registered(domain)
|
||||
instance, nodeinfo, admin_usernames = ensure_instance_registered(domain)
|
||||
if not instance:
|
||||
raise e.NotFound(f"Something went wrong trying to register this instance.")
|
||||
return instance.get_details(),200
|
||||
|
@ -62,7 +62,7 @@ class WhitelistDomain(Resource):
|
|||
self.args = self.put_parser.parse_args()
|
||||
if '@' in self.args.admin:
|
||||
raise e.BadRequest("Please send the username without any @ signs or domains")
|
||||
instance, nodeinfo, site, admin_usernames = ensure_instance_registered(domain)
|
||||
instance, nodeinfo, admin_usernames = ensure_instance_registered(domain)
|
||||
guarantor_instance = None
|
||||
if self.args.guarantor:
|
||||
guarantor_instance = database.find_instance_by_domain(self.args.guarantor)
|
||||
|
|
|
@ -13,10 +13,10 @@ def get_lemmy_admins(domain):
|
|||
|
||||
def get_mastodon_admins(domain):
|
||||
try:
|
||||
site = requests(f"https://{domain}/api/v2/instance").json()
|
||||
site = requests.get(f"https://{domain}/api/v2/instance").json()
|
||||
return [site["contact"]["account"]["username"]]
|
||||
except Exception as err:
|
||||
logger.warning(f"Error retrieving mastodon site info for {domain}")
|
||||
logger.warning(f"Error retrieving mastodon site info for {domain}: {err}")
|
||||
return None
|
||||
|
||||
def get_admin_for_software(software: str, domain: str):
|
||||
|
@ -44,5 +44,4 @@ def get_nodeinfo(domain):
|
|||
nodeinfo = requests.get(wellknown['links'][0]['href'], headers=headers, timeout=3).json()
|
||||
return nodeinfo
|
||||
except Exception as err:
|
||||
logger.debug(err)
|
||||
return None
|
Loading…
Reference in New Issue