Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
streams: Allow read access for archived channels.
Sahil Batraa06723a76391
diff --git a/api_docs/changelog.md b/api_docs/changelog.mdindex 6b832f70812..5f271632d3f 100644--- a/api_docs/changelog.md+++ b/api_docs/changelog.md@@ -20,6 +20,15 @@ format used by the Zulip server that they are interacting with.## Changes in Zulip 12.0+**Feature level 480**++* [`GET /streams/{stream_id}`](/api/get-stream-by-id): Details of+ archived channels can now be fetched.+* [`GET /streams/{stream_id}/members`](/api/get-subscribers):+ Subscribers of archived channels can now be fetched.+* [`GET /users/me/{stream_id}/topics`](/api/get-stream-topics):+ Topics in archived channels can now be fetched.+**Feature level 479*** [`GET /thumbnail/status/{realm_id_str}/{filename}`](/api/check-thumbnail-status): Addeddiff --git a/version.py b/version.pyindex 2c2d756776c..9f664d26db3 100644--- a/version.py+++ b/version.py@@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.9.3"# https://zulip.readthedocs.io/en/latest/documentation/api.html#step-by-step-guide# Also available at docs/documentation/api.md.-API_FEATURE_LEVEL = 479+API_FEATURE_LEVEL = 480# Bump the minor PROVISION_VERSION to indicate that folks should provision# only when going from an old version of the code to a newer version. Bumpdiff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yamlindex 7fd2d5a8c0d..efc68ea3fdc 100644--- a/zerver/openapi/zulip.yaml+++ b/zerver/openapi/zulip.yaml@@ -12313,6 +12313,9 @@ paths:[bot](/help/bots-overview#bot-type) will only have access to messagessent after the bot was subscribed to the channel, instead of when theuser subscribed.++ **Changes**: Before Zulip 12.0 (feature level 480), this+ endpoint was not supported for archived channels.parameters:- $ref: "#/components/parameters/ChannelIdInPath"- name: allow_empty_topic_name@@ -23053,6 +23056,9 @@ paths:tags: ["channels"]description: |Get all users subscribed to a channel.++ **Changes**: Before Zulip 12.0 (feature level 480), this+ endpoint was not supported for archived channels.parameters:- $ref: "#/components/parameters/ChannelIdInPath"responses:@@ -23366,7 +23372,10 @@ paths:description: |Fetch details for the channel with the ID `stream_id`.- **Changes**: New in Zulip 6.0 (feature level 132).+ **Changes**: Before Zulip 12.0 (feature level 480), this+ endpoint was not supported for archived channels.++ New in Zulip 6.0 (feature level 132).parameters:- $ref: "#/components/parameters/ChannelIdInPath"responses:diff --git a/zerver/tests/test_channel_fetch.py b/zerver/tests/test_channel_fetch.pyindex 17097b7891b..ad859f6542b 100644--- a/zerver/tests/test_channel_fetch.py+++ b/zerver/tests/test_channel_fetch.py@@ -439,6 +439,14 @@ class GetStreamsTest(ZulipTestCase):self.assertEqual(json["stream"]["name"], "private_stream")self.assertEqual(json["stream"]["stream_id"], private_stream.id)+ # Archived stream can also be accessed.+ do_deactivate_stream(denmark_stream, acting_user=None)+ result = self.client_get(f"/json/streams/{denmark_stream.id}")+ json = self.assert_json_success(result)+ self.assertEqual(json["stream"]["name"], "Denmark")+ self.assertEqual(json["stream"]["stream_id"], denmark_stream.id)+ self.assertTrue(json["stream"]["is_archived"])+def test_get_stream_email_address(self) -> None:self.login("hamlet")hamlet = self.example_user("hamlet")@@ -682,6 +690,19 @@ class GetSubscribersTest(ZulipTestCase):stream_name = gather_subscriptions(self.user_profile)[0][0]["name"]self.make_successful_subscriber_request(stream_name)+ def test_subscriber_archived_stream(self) -> None:+ """+ A user can fetch subscribers of an archived stream.+ """+ stream_name = "Saxony"+ self.subscribe_via_post(self.user_profile, [stream_name])+ stream = get_stream(stream_name, self.user_profile.realm)+ do_deactivate_stream(stream, acting_user=None)++ other_user = self.example_user("othello")+ self.login_user(other_user)+ self.make_successful_subscriber_request(stream_name)+@override_settings(MIN_PARTIAL_SUBSCRIBERS_CHANNEL_SIZE=5)def test_gather_partial_subscriptions(self) -> None:othello = self.example_user("othello")diff --git a/zerver/tests/test_message_topics.py b/zerver/tests/test_message_topics.pyindex 631ea999906..7758c3268c9 100644--- a/zerver/tests/test_message_topics.py+++ b/zerver/tests/test_message_topics.py@@ -4,7 +4,7 @@ from unittest import mockimport orjsonfrom django.utils.timezone import now as timezone_now-from zerver.actions.streams import do_change_stream_permission+from zerver.actions.streams import do_change_stream_permission, do_deactivate_streamfrom zerver.actions.user_topics import do_set_user_topic_visibility_policyfrom zerver.lib.events import ClientCapabilities, do_events_registerfrom zerver.lib.test_classes import ZulipTestCase@@ -852,3 +852,9 @@ class EmptyTopicNameTest(ZulipTestCase):result = self.client_get(f"/json/users/me/{channel_id}/topics", params)data = self.assert_json_success(result)self.assertEqual(data["topics"][0]["name"], "")++ do_deactivate_stream(channel_one, acting_user=None)+ result = self.client_get(f"/json/users/me/{channel_one.id}/topics")+ data = self.assert_json_success(result)+ self.assertEqual(data["topics"][0]["name"], "channel events")+ self.assertEqual(data["topics"][1]["name"], Message.EMPTY_TOPIC_FALLBACK_NAME)diff --git a/zerver/views/streams.py b/zerver/views/streams.pyindex aed7a319980..cc1a5e06b21 100644--- a/zerver/views/streams.py+++ b/zerver/views/streams.py@@ -1124,6 +1124,7 @@ def get_subscribers_backend((stream, _sub) = access_stream_by_id(user_profile,stream_id,+ require_active_channel=False,require_content_access=False,)subscribers = get_subscriber_ids(stream, user_profile)@@ -1171,7 +1172,9 @@ def get_stream_backend(*,stream_id: PathOnly[int],) -> HttpResponse:- (stream, _sub) = access_stream_by_id(user_profile, stream_id, require_content_access=False)+ (stream, _sub) = access_stream_by_id(+ user_profile, stream_id, require_active_channel=False, require_content_access=False+ )recent_traffic = get_streams_traffic(user_profile.realm, {stream.id})anonymous_group_membership = get_anonymous_group_membership_dict_for_streams([stream])@@ -1210,7 +1213,7 @@ def get_topics_backend(else:assert user_profile is not None- (stream, _sub) = access_stream_by_id(user_profile, stream_id)+ (stream, _sub) = access_stream_by_id(user_profile, stream_id, require_active_channel=False)assert stream.recipient_id is not Noneresult = get_topic_history_for_stream(