fix: Allow removing guarantee from unreachable instance
parent
8a52289333
commit
d824d9190e
|
@ -168,6 +168,7 @@ class Guarantees(Resource):
|
|||
)
|
||||
db.session.add(rejection)
|
||||
db.session.commit()
|
||||
try:
|
||||
activitypub_pm.pm_admins(
|
||||
message=f"Attention! You guarantor instance {instance.domain} has withdrawn their [guarantee](https://fediseer.com/faq#what-is-a-guarantee).\n\n"
|
||||
"IMPORTANT: The instances you vouched for are still considered guaranteed but cannot guarantee or endorse others"
|
||||
|
@ -177,14 +178,21 @@ class Guarantees(Resource):
|
|||
software=target_instance.software,
|
||||
instance=target_instance,
|
||||
)
|
||||
# We do not want a missing instance to prevent us from removing a guarantee
|
||||
except:
|
||||
pass
|
||||
orphan_ids = database.get_guarantee_chain(target_instance.id)
|
||||
for orphan in database.get_instances_by_ids(orphan_ids):
|
||||
try:
|
||||
activitypub_pm.pm_admins(
|
||||
message=f"Attention! You guarantor chain has been broken because {instance.domain} has withdrawn their backing from {domain}.\n\nIMPORTANT: All your guarantees will be deleted unless the chain is repaired or you find a new guarantor within 24hours!",
|
||||
domain=orphan.domain,
|
||||
software=orphan.software,
|
||||
instance=orphan,
|
||||
)
|
||||
# We do not want a missing instance to prevent us from removing a guarantee
|
||||
except:
|
||||
pass
|
||||
orphan.set_as_oprhan()
|
||||
logger.info(f"{instance.domain} Withdrew guarantee from {domain}")
|
||||
return {"message":'Changed'}, 200
|
||||
|
|
|
@ -7,7 +7,7 @@ def get_lemmy_admins(domain):
|
|||
requested_lemmy = Lemmy(f"https://{domain}")
|
||||
site = requested_lemmy.site.get()
|
||||
if not site:
|
||||
logger.warning(f"Error retrieving mastodon site info for {domain}")
|
||||
logger.error(f"Error retrieving mastodon site info for {domain}")
|
||||
raise Exception(f"Error retrieving mastodon site info for {domain}")
|
||||
return [a["person"]["name"] for a in site["admins"]]
|
||||
|
||||
|
@ -19,9 +19,9 @@ def get_mastodon_admins(domain):
|
|||
return [site_json["contact"]["account"]["username"]]
|
||||
except Exception as err:
|
||||
if site is not None:
|
||||
logger.warning(f"Error retrieving mastodon site info for {domain}: {err}. Request text: {site.text()}")
|
||||
logger.error(f"Error retrieving mastodon site info for {domain}: {err}. Request text: {site.text()}")
|
||||
else:
|
||||
logger.warning(f"Error retrieving mastodon site info for {domain}: {err}")
|
||||
logger.error(f"Error retrieving mastodon site info for {domain}: {err}")
|
||||
raise Exception(f"Error retrieving mastodon site info for {domain}: {err}")
|
||||
|
||||
def get_unknown_admins(domain):
|
||||
|
|
Loading…
Reference in New Issue