mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
management: Move queue_digest_recipient to digest.
This commit is contained in:
committed by
Tim Abbott
parent
2aabf4fc67
commit
9a4b17cf9b
@@ -16,6 +16,7 @@ from zerver.lib.send_email import send_future_email, FromAddress
|
||||
from zerver.models import UserProfile, UserActivity, UserMessage, Recipient, Stream, \
|
||||
Subscription, get_active_streams, get_user_profile_by_id
|
||||
from zerver.context_processors import common_context
|
||||
from zerver.lib.queue import queue_json_publish
|
||||
|
||||
import logging
|
||||
|
||||
@@ -58,6 +59,15 @@ def should_process_digest(realm_str):
|
||||
return False
|
||||
return True
|
||||
|
||||
# Changes to this should also be reflected in
|
||||
# zerver/worker/queue_processors.py:DigestWorker.consume()
|
||||
def queue_digest_recipient(user_profile, cutoff):
|
||||
# type: (UserProfile, datetime.datetime) -> None
|
||||
# Convert cutoff to epoch seconds for transit.
|
||||
event = {"user_profile_id": user_profile.id,
|
||||
"cutoff": cutoff.strftime('%s')}
|
||||
queue_json_publish("digest_emails", event, lambda event: None)
|
||||
|
||||
def gather_hot_conversations(user_profile, stream_messages):
|
||||
# type: (UserProfile, QuerySet) -> List[Dict[str, Any]]
|
||||
# Gather stream conversations of 2 types:
|
||||
|
||||
@@ -8,9 +8,8 @@ from django.conf import settings
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.utils.timezone import now as timezone_now
|
||||
|
||||
from zerver.lib.queue import queue_json_publish
|
||||
from zerver.models import UserProfile, Realm
|
||||
from zerver.lib.digest import inactive_since, should_process_digest
|
||||
from zerver.lib.digest import inactive_since, should_process_digest, queue_digest_recipient
|
||||
|
||||
## Logging setup ##
|
||||
|
||||
@@ -28,15 +27,6 @@ logger.addHandler(file_handler)
|
||||
VALID_DIGEST_DAY = 1 # Tuesdays
|
||||
DIGEST_CUTOFF = 5
|
||||
|
||||
# Changes to this should also be reflected in
|
||||
# zerver/worker/queue_processors.py:DigestWorker.consume()
|
||||
def queue_digest_recipient(user_profile, cutoff):
|
||||
# type: (UserProfile, datetime.datetime) -> None
|
||||
# Convert cutoff to epoch seconds for transit.
|
||||
event = {"user_profile_id": user_profile.id,
|
||||
"cutoff": cutoff.strftime('%s')}
|
||||
queue_json_publish("digest_emails", event, lambda event: None)
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = """Enqueue digest emails for users that haven't checked the app
|
||||
in a while.
|
||||
|
||||
Reference in New Issue
Block a user