From ebddab54ce5f04ccae55d78dae948508bb95703d Mon Sep 17 00:00:00 2001 From: vincent porte Date: Wed, 21 Jun 2023 18:51:04 +0200 Subject: [PATCH] =?UTF-8?q?feat(notification):=C2=A0cronify=20task=20send?= =?UTF-8?q?=5Fnotifs=5Fwhen=5Ffollowing=5Freplies?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clevercloud/cron.json | 1 + .../send_notifs_when_following_replies.sh | 18 ++++++++++++++++++ .../send_notifs_when_following_replies.py | 11 +++++++++++ 3 files changed, 30 insertions(+) create mode 100755 clevercloud/send_notifs_when_following_replies.sh create mode 100644 lacommunaute/notification/management/commands/send_notifs_when_following_replies.py diff --git a/clevercloud/cron.json b/clevercloud/cron.json index f4f051f25..c2823e66f 100644 --- a/clevercloud/cron.json +++ b/clevercloud/cron.json @@ -4,6 +4,7 @@ "0 5 * * * $ROOT/clevercloud/collect_daily_matomo_stats.sh", "5 5 1 * * $ROOT/clevercloud/collect_monthly_matomo_stats.sh", "5 7-21 * * * $ROOT/clevercloud/send_notifs_when_first_reply.sh", + "5 19 * * * $ROOT/clevercloud/send_notifs_when_following_replies.sh", "10 6-22 * * * $ROOT/clevercloud/add_user_to_list_when_register.sh", "30 13 * * 1 $ROOT/clevercloud/send_notifs_on_unanswered_topics_list.sh 8", "30 13 * * 2 $ROOT/clevercloud/send_notifs_on_unanswered_topics_list.sh 9", diff --git a/clevercloud/send_notifs_when_following_replies.sh b/clevercloud/send_notifs_when_following_replies.sh new file mode 100755 index 000000000..0dc3b0c30 --- /dev/null +++ b/clevercloud/send_notifs_when_following_replies.sh @@ -0,0 +1,18 @@ +#!/bin/bash -l + +# Collect Daily Matomo Stats + +# +# About clever cloud cronjobs: +# https://www.clever-cloud.com/doc/tools/crons/ +# + +if [[ "$INSTANCE_NUMBER" != "0" ]]; then + echo "Instance number is ${INSTANCE_NUMBER}. Stop here." + exit 0 +fi + +# $APP_HOME is set by default by clever cloud. +cd $APP_HOME + +python manage.py send_notifs_when_following_replies diff --git a/lacommunaute/notification/management/commands/send_notifs_when_following_replies.py b/lacommunaute/notification/management/commands/send_notifs_when_following_replies.py new file mode 100644 index 000000000..22e67b1bc --- /dev/null +++ b/lacommunaute/notification/management/commands/send_notifs_when_following_replies.py @@ -0,0 +1,11 @@ +from django.core.management.base import BaseCommand + +from lacommunaute.notification.tasks import send_notifs_on_following_replies + + +class Command(BaseCommand): + help = "Envoyer une notification par email à l'auteur d'un sujet quand il y a de nouvelles réponses" + + def handle(self, *args, **options): + send_notifs_on_following_replies() + self.stdout.write(self.style.SUCCESS("That's all, folks!"))