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.

Revert "digest: Support digest of web public streams for guest users."

Anders Kaseorg022c4fbfc7ab
diff --git a/zerver/lib/digest.py b/zerver/lib/digest.py
index 3bdd7bdbb7a..feadb985de5 100644
--- a/zerver/lib/digest.py
+++ b/zerver/lib/digest.py
@@ -148,14 +148,9 @@ def gather_hot_conversations(user_profile: UserProfile, messages: List[Message])
def gather_new_streams(user_profile: UserProfile,
threshold: datetime.datetime) -> Tuple[int, Dict[str, List[str]]]:
- if user_profile.is_guest:
- new_streams = list(get_active_streams(user_profile.realm).filter(
- is_web_public=True, date_created__gt=threshold))
-
- elif user_profile.can_access_public_streams():
+ if user_profile.can_access_public_streams():
new_streams = list(get_active_streams(user_profile.realm).filter(
invite_only=False, date_created__gt=threshold))
-
else:
new_streams = []
diff --git a/zerver/tests/test_digest.py b/zerver/tests/test_digest.py
index 982c08d3913..5fff68ca0ee 100644
--- a/zerver/tests/test_digest.py
+++ b/zerver/tests/test_digest.py
@@ -79,49 +79,6 @@ class TestDigestEmailMessages(ZulipTestCase):
self.assertIn('some content', teaser_messages[0]['content'][0]['plain'])
self.assertIn(teaser_messages[0]['sender'], expected_participants)
- @mock.patch('zerver.lib.digest.enough_traffic')
- @mock.patch('zerver.lib.digest.send_future_email')
- def test_guest_user_multiple_stream_sender(self,
- mock_send_future_email: mock.MagicMock,
- mock_enough_traffic: mock.MagicMock) -> None:
- othello = self.example_user('othello')
- hamlet = self.example_user('hamlet')
- cordelia = self.example_user('cordelia')
- polonius = self.example_user('polonius')
- create_stream_if_needed(cordelia.realm, 'web_public_stream', is_web_public=True)
- self.subscribe(othello, 'web_public_stream')
- self.subscribe(hamlet, 'web_public_stream')
- self.subscribe(cordelia, 'web_public_stream')
- self.subscribe(polonius, 'web_public_stream')
-
- one_day_ago = timezone_now() - datetime.timedelta(days=1)
- Message.objects.all().update(date_sent=one_day_ago)
- one_hour_ago = timezone_now() - datetime.timedelta(seconds=3600)
-
- cutoff = time.mktime(one_hour_ago.timetuple())
-
- senders = ['hamlet', 'cordelia', 'othello', 'desdemona']
- self.simulate_stream_conversation('web_public_stream', senders)
-
- flush_per_request_caches()
- # When this test is run in isolation, one additional query is run which
- # is equivalent to
- # ContentType.objects.get(app_label='zerver', model='userprofile')
- # This code is run when we call `confirmation.models.create_confirmation_link`.
- # To trigger this, we call the one_click_unsubscribe_link function below.
- one_click_unsubscribe_link(polonius, 'digest')
- with queries_captured() as queries:
- handle_digest_email(polonius.id, cutoff)
-
- self.assert_length(queries, 6)
-
- self.assertEqual(mock_send_future_email.call_count, 1)
- kwargs = mock_send_future_email.call_args[1]
- self.assertEqual(kwargs['to_user_ids'], [polonius.id])
-
- new_stream_names = kwargs['context']['new_streams']['plain']
- self.assertTrue('web_public_stream' in new_stream_names)
-
@mock.patch('zerver.lib.digest.enough_traffic')
@mock.patch('zerver.lib.digest.send_future_email')
def test_soft_deactivated_user_multiple_stream_senders(self,