mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +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, \
|
from zerver.models import UserProfile, UserActivity, UserMessage, Recipient, Stream, \
|
||||||
Subscription, get_active_streams, get_user_profile_by_id
|
Subscription, get_active_streams, get_user_profile_by_id
|
||||||
from zerver.context_processors import common_context
|
from zerver.context_processors import common_context
|
||||||
|
from zerver.lib.queue import queue_json_publish
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@@ -58,6 +59,15 @@ def should_process_digest(realm_str):
|
|||||||
return False
|
return False
|
||||||
return True
|
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):
|
def gather_hot_conversations(user_profile, stream_messages):
|
||||||
# type: (UserProfile, QuerySet) -> List[Dict[str, Any]]
|
# type: (UserProfile, QuerySet) -> List[Dict[str, Any]]
|
||||||
# Gather stream conversations of 2 types:
|
# Gather stream conversations of 2 types:
|
||||||
|
|||||||
@@ -8,9 +8,8 @@ from django.conf import settings
|
|||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
from django.utils.timezone import now as timezone_now
|
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.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 ##
|
## Logging setup ##
|
||||||
|
|
||||||
@@ -28,15 +27,6 @@ logger.addHandler(file_handler)
|
|||||||
VALID_DIGEST_DAY = 1 # Tuesdays
|
VALID_DIGEST_DAY = 1 # Tuesdays
|
||||||
DIGEST_CUTOFF = 5
|
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):
|
class Command(BaseCommand):
|
||||||
help = """Enqueue digest emails for users that haven't checked the app
|
help = """Enqueue digest emails for users that haven't checked the app
|
||||||
in a while.
|
in a while.
|
||||||
|
|||||||
Reference in New Issue
Block a user