From 934e179d5954533851da341528b9351d5cf87a10 Mon Sep 17 00:00:00 2001 From: Georg Krause Date: Thu, 19 Jan 2023 08:25:24 +0100 Subject: [PATCH] fix: Local instance is always reachable to itself Part-of: --- api/funkwhale_api/federation/tasks.py | 7 ++++++- api/funkwhale_api/music/models.py | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/api/funkwhale_api/federation/tasks.py b/api/funkwhale_api/federation/tasks.py index a0405f4a6..d46cd721c 100644 --- a/api/funkwhale_api/federation/tasks.py +++ b/api/funkwhale_api/federation/tasks.py @@ -633,7 +633,12 @@ def fetch_collection(url, max_pages, channel, is_page=False): def check_all_remote_instance_availability(): domains = models.Domain.objects.all().prefetch_related() for domain in domains: - check_single_remote_instance_availability(domain) + if domain == settings.FUNKWHALE_HOSTNAME: + # No need to check the instance itself: Its always reachable + domain.reachable = True + domain.last_successful_contact = timezone.now() + else: + check_single_remote_instance_availability(domain) @celery.app.task(name="federation.check_single_remote_instance_availability") diff --git a/api/funkwhale_api/music/models.py b/api/funkwhale_api/music/models.py index 8ce1fdcdd..9e4b81a15 100644 --- a/api/funkwhale_api/music/models.py +++ b/api/funkwhale_api/music/models.py @@ -1173,7 +1173,9 @@ class LibraryQuerySet(models.QuerySet): ) .values_list("target__channel__library", flat=True) ) - domains_reachable = federation_models.Domain.objects.filter(reachable=True) + domains_reachable = federation_models.Domain.objects.filter( + reachable=True + ) | federation_models.Domain.objects.filter(name=settings.FUNKWHALE_HOSTNAME) return self.filter( me_query