mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 18:36:36 +00:00
streams: Add get_metadata_access_streams_via_group_ids.
(cherry picked from commit b62d51f0ae)
This commit is contained in:
committed by
Tim Abbott
parent
1e896d9878
commit
7f85d045db
@@ -1798,3 +1798,19 @@ def send_stream_deletion_event(
|
||||
stream_ids=[stream.id for stream in streams],
|
||||
)
|
||||
send_event_on_commit(realm, stream_deletion_event, user_ids)
|
||||
|
||||
|
||||
def get_metadata_access_streams_via_group_ids(
|
||||
group_ids: list[int], realm: Realm
|
||||
) -> QuerySet[Stream]:
|
||||
"""
|
||||
Given a list of group ids, we will return streams that contains
|
||||
those group ids as a value for one of the group permission settings
|
||||
that can grant metadata access.
|
||||
"""
|
||||
return Stream.objects.filter(
|
||||
Q(can_add_subscribers_group_id__in=group_ids)
|
||||
| Q(can_administer_channel_group_id__in=group_ids)
|
||||
| Q(can_subscribe_group_id__in=group_ids),
|
||||
realm_id=realm.id,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user