stream: Show private channel for their channel admins.

Fixes https://chat.zulip.org/#narrow/channel/101-design/topic/permissions.20for.20admin.20to.20unsubscribe.20others/near/2060197
Non realm admin users were not able to view private channels they were
an administrator of but not subscribed to it. This commit changes that.
We also made changes for those users to be able to see the subscribers
list.

The increase in query count in test_home and test_event_system can be
mitigated by only fetching recursive user group ids when needed within
the `validate_user_access_to_subscribers_helper` function. But that
would require refactoring that function to handle multiple streams and
subscriptions at once, along with changing how that function is used at
different places, which might be an exercise better left as a follow up.
We have optimised the code a little bit by not fetching the group ids in
case the current user is a realm admin.

We are fetching channel_admin_ids and users belonging to
can_add_subscribers_group directly in stream_subscription.py without
using the helper function
`get_user_ids_with_metadata_access_via_permission_groups`. This is due
to a cyclic dependency and we will move `bulk_get_subscriber_peer_info`
to another file in the next commit.
This commit is contained in:
Shubham Padia
2025-01-28 19:04:34 +00:00
committed by Tim Abbott
parent 48eec43f48
commit aabf42c2ce
9 changed files with 252 additions and 40 deletions

View File

@@ -40,6 +40,10 @@ format used by the Zulip server that they are interacting with.
Previously, non-admin users who were channel admins or users
belonging to `can_add_subscribers_group` were not notified of events
for a private channel they were not subscribed to.
* [`GET /events`](/api/get-events): If a user is a channel
administrator for a private channel they are not subscribed to. That
channel will now appear either in the `unsubscribed` or
`never_subscribed` list in subscription info.
**Feature level 348**