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.
This commit is contained in:
Shubham Padia 2025-02-03 05:36:49 +00:00 committed by Tim Abbott
parent 29a1a01325
commit 03bfa7752d
2 changed files with 2 additions and 2 deletions

View File

@ -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 {

View File

@ -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);