diff --git a/fediseer/apis/v1/guarantees.py b/fediseer/apis/v1/guarantees.py index 681b7fc..eb59733 100644 --- a/fediseer/apis/v1/guarantees.py +++ b/fediseer/apis/v1/guarantees.py @@ -168,23 +168,31 @@ class Guarantees(Resource): ) db.session.add(rejection) db.session.commit() - 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" - "If you find a new guarantor then your guarantees will be reactivated!.\n\n" - "Note that if you do not find a guarantor within 7 days, all your guarantees and endorsements will be removed.", - domain=target_instance.domain, - software=target_instance.software, - instance=target_instance, - ) + 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" + "If you find a new guarantor then your guarantees will be reactivated!.\n\n" + "Note that if you do not find a guarantor within 7 days, all your guarantees and endorsements will be removed.", + domain=target_instance.domain, + 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): - 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, - ) + 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 diff --git a/fediseer/fediverse.py b/fediseer/fediverse.py index de59563..e7d47d0 100644 --- a/fediseer/fediverse.py +++ b/fediseer/fediverse.py @@ -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):