def do_delete_messages(realm: Realm, messages: Iterable[Message]) -> None:
    messages = list(messages)
    message_ids = [message.id for message in messages]
    if (not message_ids):
        return
    event: DeleteMessagesEvent = {'type': 'delete_message', 'message_ids': message_ids}
    sample_message = messages[0]
    message_type = 'stream'
    users_to_notify = []
    if (not sample_message.is_stream_message()):
        assert (len(messages) == 1)
        message_type = 'private'
        ums = UserMessage.objects.filter(message_id__in=message_ids)
        users_to_notify = [um.user_profile_id for um in ums]
        event['recipient_id'] = sample_message.recipient_id
        event['sender_id'] = sample_message.sender_id
        archiving_chunk_size = retention.MESSAGE_BATCH_SIZE
    if (message_type == 'stream'):
        stream_id = sample_message.recipient.type_id
        event['stream_id'] = stream_id
        event['topic'] = sample_message.topic_name()
        subscribers = get_active_subscriptions_for_stream_id(stream_id)
        subscribers = subscribers.exclude(user_profile__long_term_idle=True)
        subscriber_ids = [user.user_profile_id for user in subscribers]
        users_to_notify = list(map(subscriber_info, subscriber_ids))
        archiving_chunk_size = retention.STREAM_MESSAGE_BATCH_SIZE
    move_messages_to_archive(message_ids, realm=realm, chunk_size=archiving_chunk_size)
    event['message_type'] = message_type
    send_event(realm, event, users_to_notify)
def do_delete_messages(realm: Realm, messages: Iterable[Message]) -> None:
    messages = list(messages)
    message_ids = [message.id for message in messages]
    if (not message_ids):
        return
    event: DeleteMessagesEvent = {'type': 'delete_message', 'message_ids': message_ids}
    sample_message = messages[0]
    message_type = 'stream'
    users_to_notify = []
    if (not sample_message.is_stream_message()):
        assert (len(messages) == 1)
        message_type = 'private'
        ums = UserMessage.objects.filter(message_id__in=message_ids)
        users_to_notify = [um.user_profile_id for um in ums]
        event['recipient_id'] = sample_message.recipient_id
        event['sender_id'] = sample_message.sender_id
        archiving_chunk_size = retention.MESSAGE_BATCH_SIZE
    if (message_type == 'stream'):
        stream_id = sample_message.recipient.type_id
        event['stream_id'] = stream_id
        event['topic'] = sample_message.topic_name()
        subscribers = get_active_subscriptions_for_stream_id(stream_id)
        subscribers = subscribers.exclude(user_profile__long_term_idle=True)
        subscriber_ids = [user.user_profile_id for user in subscribers]
        users_to_notify = list(map(subscriber_info, subscriber_ids))
        archiving_chunk_size = retention.STREAM_MESSAGE_BATCH_SIZE
    move_messages_to_archive(message_ids, realm=realm, chunk_size=archiving_chunk_size)
    event['message_type'] = message_type
    send_event(realm, event, users_to_notify)