Skip to content

Commit

Permalink
use api domain if exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Her Email authored and alphatownsman committed Nov 10, 2023
1 parent d611955 commit e28e2bc
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions mastodon/jobs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from datetime import timedelta

from django.db.models import Q
from django.utils import timezone
from loguru import logger

Expand All @@ -17,14 +18,20 @@ def run(self):
count_checked = 0
count_unreachable = 0
count_disabled = 0
for site in MastodonApplication.objects.exclude(disabled=True):
q = Q(last_reachable_date__lte=timezone.now() - timedelta(days=1)) | Q(
last_reachable_date__isnull=True
)
for site in MastodonApplication.objects.exclude(disabled=True).filter(q):
domain = None
count_checked += 1
try:
domain, api_domain, v = detect_server_info(site.domain_name)
api_domain = site.api_domain or site.domain_name
domain, api_domain, v = detect_server_info(api_domain)
site.last_reachable_date = timezone.now()
except:
logger.warning(f"Failed to detect server info for {site.domain_name}")
logger.warning(
f"Failed to detect server info for {site.domain_name}/{site.api_domain}"
)
count_unreachable += 1
if site.last_reachable_date is None:
site.last_reachable_date = timezone.now() - timedelta(days=1)
Expand Down

0 comments on commit e28e2bc

Please sign in to comment.