get_stream: Rename include_all_active to include_all.

We keep around the old `include_all_active` parameter for backwards
compatibility.
Web frontend doesn't use this API and thus there were no changes needed
there.
This commit is contained in:
Shubham Padia
2025-02-24 21:20:55 +00:00
committed by Tim Abbott
parent 6dde44cf37
commit ce031c4b52
8 changed files with 52 additions and 17 deletions

View File

@@ -25,6 +25,9 @@ format used by the Zulip server that they are interacting with.
* [`GET /streams`](/api/get-streams): The new parameter
`include_can_access_content`, if set to True, returns all the
channels that the user making the request has content access to.
* [`GET /streams`](/api/get-streams): Rename `include_all_active` to
`include_all` since the separate `exclude_archived` parameter is what
controls whether to include archived channels.
**Feature level 355**

View File

@@ -549,7 +549,7 @@ def send_stream_events_for_role_update(
) -> None:
current_accessible_streams = get_streams_for_user(
user_profile,
include_all_active=user_profile.is_realm_admin,
include_all=user_profile.is_realm_admin,
include_web_public=True,
)
@@ -621,7 +621,7 @@ def do_change_user_role(
previously_accessible_streams = get_streams_for_user(
user_profile,
include_web_public=True,
include_all_active=user_profile.is_realm_admin,
include_all=user_profile.is_realm_admin,
)
user_profile.role = value

View File

@@ -721,7 +721,7 @@ def fetch_initial_state_data(
state["streams"] = do_get_streams(
user_profile,
include_web_public=True,
include_all_active=user_profile.is_realm_admin,
include_all=user_profile.is_realm_admin,
)
else:
# TODO: This line isn't used by the web app because it

View File

@@ -1441,11 +1441,11 @@ def get_streams_for_user(
include_web_public: bool = False,
include_subscribed: bool = True,
exclude_archived: bool = True,
include_all_active: bool = False,
include_all: bool = False,
include_owner_subscribed: bool = False,
include_can_access_content: bool = False,
) -> list[Stream]:
if include_all_active and not user_profile.is_realm_admin:
if include_all and not user_profile.is_realm_admin:
raise JsonableError(_("User not authorized for this query"))
include_public = include_public and user_profile.can_access_public_streams()
@@ -1458,7 +1458,7 @@ def get_streams_for_user(
if exclude_archived:
query = query.filter(deactivated=False)
if include_all_active:
if include_all:
streams = query.only(
*Stream.API_FIELDS, "can_send_message_group", "can_send_message_group__named_user_group"
)
@@ -1614,7 +1614,7 @@ def do_get_streams(
include_web_public: bool = False,
include_subscribed: bool = True,
exclude_archived: bool = True,
include_all_active: bool = False,
include_all: bool = False,
include_default: bool = False,
include_owner_subscribed: bool = False,
include_can_access_content: bool = False,
@@ -1627,7 +1627,7 @@ def do_get_streams(
include_web_public,
include_subscribed,
exclude_archived,
include_all_active,
include_all,
include_owner_subscribed,
include_can_access_content,
)

View File

@@ -827,7 +827,7 @@ def get_user_groups(client: Client) -> int:
def test_user_not_authorized_error(nonadmin_client: Client) -> None:
result = nonadmin_client.get_streams(include_all_active=True)
result = nonadmin_client.get_streams(include_all=True)
assert_error_response(result)
validate_against_openapi_schema(result, "/rest-error-handling", "post", "400")

View File

@@ -20340,8 +20340,31 @@ paths:
- name: include_all_active
in: query
description: |
Include all active channels. The user must have administrative privileges
to use this parameter.
Deprecated parameter to include all channels. The user must
have administrative privileges to use this parameter.
**Changes**: Deprecated in Zulip 10.0 (feature level
356). Clients interacting with newer servers should use
the equivalent `include_all` parameter, which does not
incorrectly hint that this parameter, and not
`exclude_archived`, controls whether archived channels
appear in the response.
schema:
type: boolean
default: false
deprecated: true
example: true
- name: include_all
in: query
description: |
Include all channels that the user has metadata access to.
For organization administrators, this will be all channels
in the organization, since organization administrators
implicitly have metadata access to all channels.
**Changes**: New in Zulip 10.0 (feature level 356). On older
versions, use `include_all_active`, which this replaces.
schema:
type: boolean
default: false
@@ -20525,7 +20548,7 @@ paths:
}
description: |
An example JSON response for when the user is not authorized to use the
`include_all_active` parameter (i.e. because they are not an organization
`include_all` parameter (i.e. because they are not an organization
administrator):
/streams/{stream_id}:
get:

View File

@@ -246,7 +246,7 @@ class TestMiscStuff(ZulipTestCase):
user_profile=user_profile,
include_public=False,
include_subscribed=False,
include_all_active=False,
include_all=False,
include_default=False,
)
self.assertEqual(streams, [])
@@ -3219,7 +3219,7 @@ class StreamAdminTest(ZulipTestCase):
# It shows up with `exclude_archived` parameter set to false.
result = self.client_get(
"/json/streams", {"exclude_archived": "false", "include_all_active": "true"}
"/json/streams", {"exclude_archived": "false", "include_all": "true"}
)
streams = [s["name"] for s in self.assert_json_success(result)["streams"]]
self.assertIn(deactivated_stream_name, streams)
@@ -6883,9 +6883,10 @@ class GetStreamsTest(ZulipTestCase):
def test_all_active_streams_api(self) -> None:
url = "/api/v1/streams"
data = {"include_all_active": "true"}
data = {"include_all": "true"}
backward_compatible_data = {"include_all_active": "true"}
# Check non-superuser can't use include_all_active
# Check non-superuser can't use include_all
normal_user = self.example_user("cordelia")
result = self.api_get(normal_user, url, data)
self.assertEqual(result.status_code, 400)
@@ -6897,6 +6898,11 @@ class GetStreamsTest(ZulipTestCase):
result = self.api_get(admin_user, url, data)
json = self.assert_json_success(result)
backward_compatible_result = self.api_get(admin_user, url, backward_compatible_data)
json_for_backward_compatible_request = self.assert_json_success(backward_compatible_result)
self.assertEqual(json, json_for_backward_compatible_request)
self.assertIn("streams", json)
self.assertIsInstance(json["streams"], list)

View File

@@ -925,18 +925,21 @@ def get_streams_backend(
include_web_public: Json[bool] = False,
include_subscribed: Json[bool] = True,
exclude_archived: Json[bool] = True,
include_all: Json[bool] = False,
include_all_active: Json[bool] = False,
include_default: Json[bool] = False,
include_owner_subscribed: Json[bool] = False,
include_can_access_content: Json[bool] = False,
) -> HttpResponse:
if include_all_active is True:
include_all = True
streams = do_get_streams(
user_profile,
include_public=include_public,
include_web_public=include_web_public,
include_subscribed=include_subscribed,
exclude_archived=exclude_archived,
include_all_active=include_all_active,
include_all=include_all,
include_default=include_default,
include_owner_subscribed=include_owner_subscribed,
include_can_access_content=include_can_access_content,