2013-10-21 23:26:23 +02:00
|
|
|
import datetime
|
|
|
|
|
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-08-27 16:30:48 +02:00
|
|
|
from zerver.lib.digest import enqueue_emails, DIGEST_CUTOFF
|
2017-08-25 15:25:00 +02:00
|
|
|
from zerver.lib.logging_util import create_logger
|
2013-10-21 23:26:23 +02:00
|
|
|
|
2013-12-16 23:03:09 +01:00
|
|
|
## Logging setup ##
|
2017-08-25 15:25:00 +02:00
|
|
|
logger = create_logger(__name__, settings.DIGEST_LOG_PATH, 'DEBUG')
|
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)
|