2013-10-21 23:26:23 +02:00
|
|
|
import datetime
|
2017-12-13 01:45:57 +01:00
|
|
|
import logging
|
2017-03-03 19:01:52 +01:00
|
|
|
from typing import Any, List
|
2016-06-04 16:52:18 +02:00
|
|
|
|
2013-12-16 23:03:09 +01:00
|
|
|
from django.conf import settings
|
2013-10-21 23:26:23 +02:00
|
|
|
from django.core.management.base import BaseCommand
|
2017-04-15 04:03:56 +02:00
|
|
|
from django.utils.timezone import now as timezone_now
|
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
|
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
|
|
|
|
2013-10-21 23:26:23 +02:00
|
|
|
class Command(BaseCommand):
|
|
|
|
help = """Enqueue digest emails for users that haven't checked the app
|
|
|
|
in a while.
|
|
|
|
"""
|
2016-11-29 07:22:02 +01:00
|
|
|
|
2017-10-26 11:35:57 +02:00
|
|
|
def handle(self, *args: Any, **options: Any) -> None:
|
2017-08-27 16:30:48 +02:00
|
|
|
cutoff = timezone_now() - datetime.timedelta(days=DIGEST_CUTOFF)
|
|
|
|
enqueue_emails(cutoff)
|