From a0e8a37e7f15347f288046bbda9ccb255686a43a Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Wed, 2 May 2018 08:52:54 -0700 Subject: [PATCH] topics: Fix get_topics_backend logic for zephyr realms. This removes a check on invite_only, that should have been a check on history_public_to_subscribers. In addition to fixing a bug for zephyr realms, it also makes "more topics" work correctly for realms using the new settings for stream history being public to subscribers. --- zerver/tests/test_messages.py | 20 ++++++++++++++++++++ zerver/views/streams.py | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/zerver/tests/test_messages.py b/zerver/tests/test_messages.py index 246de9b2f3..387a1b4f81 100644 --- a/zerver/tests/test_messages.py +++ b/zerver/tests/test_messages.py @@ -88,6 +88,26 @@ from typing import Any, Dict, List, Optional, Set, Text from collections import namedtuple class TopicHistoryTest(ZulipTestCase): + def test_topics_history_zephyr_mirror(self) -> None: + user_profile = self.mit_user('sipbtest') + stream_name = 'new_stream' + + # Send a message to this new stream from another user + self.subscribe(self.mit_user("starnine"), stream_name) + stream = get_stream(stream_name, user_profile.realm) + self.send_stream_message(self.mit_email("starnine"), stream_name, + topic_name="secret topic", sender_realm="zephyr") + + # Now subscribe this MIT user to the new stream and verify + # that the new topic is not accessible + self.login(user_profile.email, realm=user_profile.realm) + self.subscribe(user_profile, stream_name) + endpoint = '/json/users/me/%d/topics' % (stream.id,) + result = self.client_get(endpoint, dict(), subdomain="zephyr") + self.assert_json_success(result) + history = result.json()['topics'] + self.assertEqual(history, []) + def test_topics_history(self) -> None: # verified: int(UserMessage.flags.read) == 1 user_profile = self.example_user('iago') diff --git a/zerver/views/streams.py b/zerver/views/streams.py index 9e0721b833..9c24adf1d5 100644 --- a/zerver/views/streams.py +++ b/zerver/views/streams.py @@ -444,7 +444,7 @@ def get_topics_backend(request: HttpRequest, user_profile: UserProfile, result = get_topic_history_for_stream( user_profile=user_profile, recipient=recipient, - public_history=not stream.invite_only, + public_history=stream.is_history_public_to_subscribers(), ) return json_success(dict(topics=result))