def get_peer_user_ids_for_stream_change(stream: Stream, altered_user_ids: Iterable[int], subscribed_user_ids: Iterable[int]) -> Set[int]:
    '\n    altered_user_ids is the user_ids that we are adding/removing\n    subscribed_user_ids is the already-subscribed user_ids\n\n    Based on stream policy, we notify the correct bystanders, while\n    not notifying altered_users (who get subscribers via another event)\n    '
    if stream.invite_only:
        realm_admin_ids = [user.id for user in stream.realm.get_admin_users_and_bots()]
        user_ids_to_notify = []
        user_ids_to_notify.extend(realm_admin_ids)
        user_ids_to_notify.extend(subscribed_user_ids)
        return (set(user_ids_to_notify) - set(altered_user_ids))
    else:
        return (set(active_non_guest_user_ids(stream.realm_id)) - set(altered_user_ids))
altered_user_ids is the user_ids that we are adding/removing
subscribed_user_ids is the already-subscribed user_ids

Based on stream policy, we notify the correct bystanders, while
not notifying altered_users (who get subscribers via another event)
def get_peer_user_ids_for_stream_change(stream: Stream, altered_user_ids: Iterable[int], subscribed_user_ids: Iterable[int]) -> Set[int]:
    '\n    altered_user_ids is the user_ids that we are adding/removing\n    subscribed_user_ids is the already-subscribed user_ids\n\n    Based on stream policy, we notify the correct bystanders, while\n    not notifying altered_users (who get subscribers via another event)\n    '
    if stream.invite_only:
        realm_admin_ids = [user.id for user in stream.realm.get_admin_users_and_bots()]
        user_ids_to_notify = []
        user_ids_to_notify.extend(realm_admin_ids)
        user_ids_to_notify.extend(subscribed_user_ids)
        return (set(user_ids_to_notify) - set(altered_user_ids))
    else:
        return (set(active_non_guest_user_ids(stream.realm_id)) - set(altered_user_ids))