2013-10-21 23:26:23 +02:00
|
|
|
from __future__ import absolute_import
|
|
|
|
import datetime
|
2013-12-16 23:03:09 +01:00
|
|
|
import logging
|
2013-10-21 23:26:23 +02:00
|
|
|
|
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
|
2013-10-21 23:26:23 +02:00
|
|
|
|
2013-12-16 23:03:09 +01:00
|
|
|
## Logging setup ##
|
|
|
|
|
|
|
|
log_format = "%(asctime)s: %(message)s"
|
|
|
|
logging.basicConfig(format=log_format)
|
|
|
|
|
|
|
|
formatter = logging.Formatter(log_format)
|
|
|
|
file_handler = logging.FileHandler(settings.DIGEST_LOG_PATH)
|
|
|
|
file_handler.setFormatter(formatter)
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
logger.setLevel(logging.DEBUG)
|
|
|
|
logger.addHandler(file_handler)
|
|
|
|
|
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
|
|
|
|
2013-10-21 23:26:23 +02:00
|
|
|
def handle(self, *args, **options):
|
2016-06-04 16:52:18 +02:00
|
|
|
# type: (*Any, **Any) -> None
|
2017-08-27 16:30:48 +02:00
|
|
|
cutoff = timezone_now() - datetime.timedelta(days=DIGEST_CUTOFF)
|
|
|
|
enqueue_emails(cutoff)
|