From c0f920544b20a037742c8ff252097a99f7d60b8e Mon Sep 17 00:00:00 2001 From: moanos Date: Sun, 20 Jul 2025 13:49:24 +0200 Subject: [PATCH] feat: Add automatic post in the evening --- src/fellchensammlung/tasks.py | 10 +++++++++- src/notfellchen/celery.py | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/fellchensammlung/tasks.py b/src/fellchensammlung/tasks.py index a5b179c..722e118 100644 --- a/src/fellchensammlung/tasks.py +++ b/src/fellchensammlung/tasks.py @@ -5,8 +5,9 @@ from django.utils import timezone from notfellchen.celery import app as celery_app from .mail import send_notification_email from .tools.admin import clean_locations, deactivate_unchecked_adoption_notices, deactivate_404_adoption_notices +from .tools.fedi import post_an_to_fedi from .tools.misc import healthcheck_ok -from .models import Location, AdoptionNotice, Timestamp, RescueOrganization +from .models import Location, AdoptionNotice, Timestamp, RescueOrganization, SocialMediaPost from .tools.notifications import notify_of_AN_to_be_checked from .tools.search import notify_search_subscribers @@ -38,6 +39,13 @@ def task_deactivate_unchecked(): set_timestamp("task_deactivate_404_adoption_notices") +@celery_app.task(name="social_media.post_fedi") +def task_post_to_fedi(): + adoption_notice = SocialMediaPost.get_an_to_post() + post_an_to_fedi(adoption_notice) + set_timestamp("task_social_media.post_fedi") + + @celery_app.task(name="commit.post_an_save") def post_adoption_notice_save(pk): instance = AdoptionNotice.objects.get(pk=pk) diff --git a/src/notfellchen/celery.py b/src/notfellchen/celery.py index dfd2553..f441e53 100644 --- a/src/notfellchen/celery.py +++ b/src/notfellchen/celery.py @@ -24,6 +24,11 @@ app.conf.beat_schedule = { 'task': 'admin.deactivate_404_adoption_notices', 'schedule': crontab(hour=3), }, + 'daily-fedi-post': { + 'task': 'social_media.post_fedi', + 'schedule': crontab(hour=19), + }, + } if settings.HEALTHCHECKS_URL is not None and settings.HEALTHCHECKS_URL != "":