fix: Allow removing guarantee from unreachable instance
parent
8a52289333
commit
d824d9190e
|
@ -168,23 +168,31 @@ class Guarantees(Resource):
|
||||||
)
|
)
|
||||||
db.session.add(rejection)
|
db.session.add(rejection)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
activitypub_pm.pm_admins(
|
try:
|
||||||
message=f"Attention! You guarantor instance {instance.domain} has withdrawn their [guarantee](https://fediseer.com/faq#what-is-a-guarantee).\n\n"
|
activitypub_pm.pm_admins(
|
||||||
"IMPORTANT: The instances you vouched for are still considered guaranteed but cannot guarantee or endorse others"
|
message=f"Attention! You guarantor instance {instance.domain} has withdrawn their [guarantee](https://fediseer.com/faq#what-is-a-guarantee).\n\n"
|
||||||
"If you find a new guarantor then your guarantees will be reactivated!.\n\n"
|
"IMPORTANT: The instances you vouched for are still considered guaranteed but cannot guarantee or endorse others"
|
||||||
"Note that if you do not find a guarantor within 7 days, all your guarantees and endorsements will be removed.",
|
"If you find a new guarantor then your guarantees will be reactivated!.\n\n"
|
||||||
domain=target_instance.domain,
|
"Note that if you do not find a guarantor within 7 days, all your guarantees and endorsements will be removed.",
|
||||||
software=target_instance.software,
|
domain=target_instance.domain,
|
||||||
instance=target_instance,
|
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)
|
orphan_ids = database.get_guarantee_chain(target_instance.id)
|
||||||
for orphan in database.get_instances_by_ids(orphan_ids):
|
for orphan in database.get_instances_by_ids(orphan_ids):
|
||||||
activitypub_pm.pm_admins(
|
try:
|
||||||
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!",
|
activitypub_pm.pm_admins(
|
||||||
domain=orphan.domain,
|
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!",
|
||||||
software=orphan.software,
|
domain=orphan.domain,
|
||||||
instance=orphan,
|
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()
|
orphan.set_as_oprhan()
|
||||||
logger.info(f"{instance.domain} Withdrew guarantee from {domain}")
|
logger.info(f"{instance.domain} Withdrew guarantee from {domain}")
|
||||||
return {"message":'Changed'}, 200
|
return {"message":'Changed'}, 200
|
||||||
|
|
|
@ -7,7 +7,7 @@ def get_lemmy_admins(domain):
|
||||||
requested_lemmy = Lemmy(f"https://{domain}")
|
requested_lemmy = Lemmy(f"https://{domain}")
|
||||||
site = requested_lemmy.site.get()
|
site = requested_lemmy.site.get()
|
||||||
if not site:
|
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}")
|
raise Exception(f"Error retrieving mastodon site info for {domain}")
|
||||||
return [a["person"]["name"] for a in site["admins"]]
|
return [a["person"]["name"] for a in site["admins"]]
|
||||||
|
|
||||||
|
@ -19,9 +19,9 @@ def get_mastodon_admins(domain):
|
||||||
return [site_json["contact"]["account"]["username"]]
|
return [site_json["contact"]["account"]["username"]]
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
if site is not None:
|
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:
|
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}")
|
raise Exception(f"Error retrieving mastodon site info for {domain}: {err}")
|
||||||
|
|
||||||
def get_unknown_admins(domain):
|
def get_unknown_admins(domain):
|
||||||
|
|
Loading…
Reference in New Issue