Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

email digests: Avoid long_term_idle check.

Steve Howell52e2d5a73340
diff --git a/zerver/lib/digest.py b/zerver/lib/digest.py
index d67d60e1ac3..96ab15b34bd 100644
--- a/zerver/lib/digest.py
+++ b/zerver/lib/digest.py
@@ -243,18 +243,13 @@ def bulk_get_digest_context(users: List[UserProfile], cutoff: float) -> Dict[int
stream_map = get_stream_map(user_ids)
- long_term_idle_user_ids = [user.id for user in users if user.long_term_idle]
-
- recently_modified_streams = get_modified_streams(long_term_idle_user_ids, cutoff_date)
+ recently_modified_streams = get_modified_streams(user_ids, cutoff_date)
all_stream_ids = set()
for user in users:
stream_ids = stream_map[user.id]
-
- if user.long_term_idle:
- stream_ids -= recently_modified_streams.get(user.id, set())
-
+ stream_ids -= recently_modified_streams.get(user.id, set())
all_stream_ids |= stream_ids
# Get all the recent topics for all the users. This does the heavy
diff --git a/zerver/tests/test_digest.py b/zerver/tests/test_digest.py
index 9f4142800a9..8262d066335 100644
--- a/zerver/tests/test_digest.py
+++ b/zerver/tests/test_digest.py
@@ -55,6 +55,9 @@ class TestDigestEmailMessages(ZulipTestCase):
senders = ['hamlet', 'cordelia', 'iago', 'prospero', 'ZOE']
self.simulate_stream_conversation('Verona', senders)
+ # Remove RealmAuditoLog rows, so we don't exclude polonius.
+ RealmAuditLog.objects.all().delete()
+
flush_per_request_caches()
# When this test is run in isolation, one additional query is run which
# is equivalent to
@@ -65,7 +68,7 @@ class TestDigestEmailMessages(ZulipTestCase):
with queries_captured() as queries:
handle_digest_email(othello.id, cutoff)
- self.assert_length(queries, 10)
+ self.assert_length(queries, 11)
self.assertEqual(mock_send_future_email.call_count, 1)
kwargs = mock_send_future_email.call_args[1]
@@ -108,6 +111,9 @@ class TestDigestEmailMessages(ZulipTestCase):
senders = ['hamlet', 'cordelia', 'othello', 'desdemona']
self.simulate_stream_conversation('web_public_stream', senders)
+ # Remove RealmAuditoLog rows, so we don't exclude polonius.
+ RealmAuditLog.objects.all().delete()
+
flush_per_request_caches()
# When this test is run in isolation, one additional query is run which
# is equivalent to
@@ -118,7 +124,7 @@ class TestDigestEmailMessages(ZulipTestCase):
with queries_captured() as queries:
handle_digest_email(polonius.id, cutoff)
- self.assert_length(queries, 10)
+ self.assert_length(queries, 11)
self.assertEqual(mock_send_future_email.call_count, 1)
kwargs = mock_send_future_email.call_args[1]
@@ -145,10 +151,6 @@ class TestDigestEmailMessages(ZulipTestCase):
RealmAuditLog.objects.all().delete()
- for digest_user in digest_users:
- digest_user.long_term_idle = True
- digest_user.save(update_fields=['long_term_idle'])
-
# Send messages to a stream and unsubscribe - subscribe from that stream
senders = ['hamlet', 'cordelia', 'iago', 'prospero', 'ZOE']
self.simulate_stream_conversation('Verona', senders)