streams: Rename admin_access_required to unsubscribing_others.

This commit renames admin_access_required parameter of
list_to_streams function to unsubscribing_others since that
parameter is used and passed as True only when calling
the function while unsubscribing others and in further
commits we would allow non-admins too to unsubscribe others
based on can_remove_subscribers_group setting.
This commit is contained in:
Sahil Batra 2022-07-13 15:45:13 +05:30 committed by Tim Abbott
parent bcef35490d
commit 52c8f687cc
2 changed files with 3 additions and 3 deletions

View File

@ -625,7 +625,7 @@ def list_to_streams(
streams_raw: Collection[StreamDict], streams_raw: Collection[StreamDict],
user_profile: UserProfile, user_profile: UserProfile,
autocreate: bool = False, autocreate: bool = False,
admin_access_required: bool = False, unsubscribing_others: bool = False,
) -> Tuple[List[Stream], List[Stream]]: ) -> Tuple[List[Stream], List[Stream]]:
"""Converts list of dicts to a list of Streams, validating input in the process """Converts list of dicts to a list of Streams, validating input in the process
@ -654,7 +654,7 @@ def list_to_streams(
missing_stream_dicts: List[StreamDict] = [] missing_stream_dicts: List[StreamDict] = []
existing_stream_map = bulk_get_streams(user_profile.realm, stream_set) existing_stream_map = bulk_get_streams(user_profile.realm, stream_set)
if admin_access_required: if unsubscribing_others:
existing_recipient_ids = [stream.recipient_id for stream in existing_stream_map.values()] existing_recipient_ids = [stream.recipient_id for stream in existing_stream_map.values()]
subs = Subscription.objects.filter( subs = Subscription.objects.filter(
user_profile=user_profile, recipient_id__in=existing_recipient_ids, active=True user_profile=user_profile, recipient_id__in=existing_recipient_ids, active=True

View File

@ -424,7 +424,7 @@ def remove_subscriptions_backend(
streams_as_dict.append({"name": stream_name.strip()}) streams_as_dict.append({"name": stream_name.strip()})
streams, __ = list_to_streams( streams, __ = list_to_streams(
streams_as_dict, user_profile, admin_access_required=removing_someone_else streams_as_dict, user_profile, unsubscribing_others=removing_someone_else
) )
if principals: if principals: