def do_change_stream_invite_only(stream: Stream, invite_only: bool, history_public_to_subscribers: Optional[bool]=None) -> None:
    history_public_to_subscribers = get_default_value_for_history_public_to_subscribers(stream.realm, invite_only, history_public_to_subscribers)
    stream.invite_only = invite_only
    stream.history_public_to_subscribers = history_public_to_subscribers
    stream.save(update_fields=['invite_only', 'history_public_to_subscribers'])
    event = dict(op='update', type='stream', property='invite_only', value=invite_only, history_public_to_subscribers=history_public_to_subscribers, stream_id=stream.id, name=stream.name)
    send_event(stream.realm, event, can_access_stream_user_ids(stream))
def do_change_stream_invite_only(stream: Stream, invite_only: bool, history_public_to_subscribers: Optional[bool]=None) -> None:
    history_public_to_subscribers = get_default_value_for_history_public_to_subscribers(stream.realm, invite_only, history_public_to_subscribers)
    stream.invite_only = invite_only
    stream.history_public_to_subscribers = history_public_to_subscribers
    stream.save(update_fields=['invite_only', 'history_public_to_subscribers'])
    event = dict(op='update', type='stream', property='invite_only', value=invite_only, history_public_to_subscribers=history_public_to_subscribers, stream_id=stream.id, name=stream.name)
    send_event(stream.realm, event, can_access_stream_user_ids(stream))