From 03bfa7752dd9d510bfd480f9ddedfba74c754d8a Mon Sep 17 00:00:00 2001 From: Shubham Padia Date: Mon, 3 Feb 2025 05:36:49 +0000 Subject: [PATCH] stream_data: Use has_metadata_access for can_view_subscribers. We are using `has_metadata_access` one by one in different functions in stream_data where possible. This commit does not represent the exhaustive use of `has_metadata_access`. We have kept around the `can_view_subscribers` function even though it is the same as `has_metadata_access` right now. Since we've already done the work of using `can_view_subscribers` at appropriate places, it would be good to keep that work around in case that function's underlying implementation changes in the future. --- web/src/stream_data.ts | 3 +-- web/tests/stream_data.test.cjs | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/web/src/stream_data.ts b/web/src/stream_data.ts index 45e25cb81b..54575a832f 100644 --- a/web/src/stream_data.ts +++ b/web/src/stream_data.ts @@ -596,8 +596,7 @@ export function can_edit_description(sub: StreamSubscription): boolean { } export function can_view_subscribers(sub: StreamSubscription): boolean { - // Guest users can't access subscribers of any(public or private) non-subscribed streams. - return current_user.is_admin || sub.subscribed || (!current_user.is_guest && !sub.invite_only); + return has_metadata_access(sub); } export function can_subscribe_others(sub: StreamSubscription): boolean { diff --git a/web/tests/stream_data.test.cjs b/web/tests/stream_data.test.cjs index 06d704bec7..348466fa45 100644 --- a/web/tests/stream_data.test.cjs +++ b/web/tests/stream_data.test.cjs @@ -1232,6 +1232,7 @@ test("can_unsubscribe_others", ({override}) => { stream_id: 1, can_remove_subscribers_group: admins_group.id, can_administer_channel_group: nobody_group.id, + can_add_subscribers_group: nobody_group.id, }; stream_data.add_sub(sub);