2017-12-13 01:45:57 +01:00
|
|
|
import logging
|
2023-11-19 19:45:19 +01:00
|
|
|
from datetime import timedelta
|
2019-02-02 23:53:29 +01:00
|
|
|
from typing import Any
|
2016-06-04 16:52:18 +02:00
|
|
|
|
2013-12-16 23:03:09 +01:00
|
|
|
from django.conf import settings
|
2017-04-15 04:03:56 +02:00
|
|
|
from django.utils.timezone import now as timezone_now
|
2023-10-12 19:43:45 +02:00
|
|
|
from typing_extensions import override
|
2013-10-21 23:26:23 +02:00
|
|
|
|
2017-11-16 00:43:27 +01:00
|
|
|
from zerver.lib.digest import DIGEST_CUTOFF, enqueue_emails
|
2017-12-13 01:45:57 +01:00
|
|
|
from zerver.lib.logging_util import log_to_file
|
2024-05-24 16:49:56 +02:00
|
|
|
from zerver.lib.management import ZulipBaseCommand, abort_unless_locked
|
2013-10-21 23:26:23 +02:00
|
|
|
|
2013-12-16 23:03:09 +01:00
|
|
|
## Logging setup ##
|
2017-12-13 01:45:57 +01:00
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
log_to_file(logger, settings.DIGEST_LOG_PATH)
|
2013-12-16 23:03:09 +01:00
|
|
|
|
2021-02-12 08:19:30 +01:00
|
|
|
|
2024-05-24 16:49:56 +02:00
|
|
|
class Command(ZulipBaseCommand):
|
2013-10-21 23:26:23 +02:00
|
|
|
help = """Enqueue digest emails for users that haven't checked the app
|
|
|
|
in a while.
|
|
|
|
"""
|
2016-11-29 07:22:02 +01:00
|
|
|
|
2023-10-12 19:43:45 +02:00
|
|
|
@override
|
2024-04-23 21:30:37 +02:00
|
|
|
@abort_unless_locked
|
2017-10-26 11:35:57 +02:00
|
|
|
def handle(self, *args: Any, **options: Any) -> None:
|
2023-11-19 19:45:19 +01:00
|
|
|
cutoff = timezone_now() - timedelta(days=DIGEST_CUTOFF)
|
2017-08-27 16:30:48 +02:00
|
|
|
enqueue_emails(cutoff)
|