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

This reverts commit c3779338c6 (part
of #14638), which incorrectly depended on commits from the future,
with the effect of either halting the flow of entropic time in an
irresolvable temporal paradox, summoning extradimensional beings to
rain destruction on the galaxy, or failing CI.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2020-07-29 20:48:04 -07:00
parent c3779338c6
commit 022c4fbfc7
2 changed files with 1 additions and 49 deletions

View File

@ -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 = []

View File

@ -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,