def _internal_prep_message(realm: Realm, sender: UserProfile, addressee: Addressee, content: str) -> Optional[Dict[(str, Any)]]:
    "\n    Create a message object and checks it, but doesn't send it or save it to the database.\n    The internal function that calls this can therefore batch send a bunch of created\n    messages together as one database query.\n    Call do_send_messages with a list of the return values of this method.\n    "
    if (len(content) > MAX_MESSAGE_LENGTH):
        content = (content[0:3900] + '\n\n[message was too long and has been truncated]')
    if addressee.is_stream():
        stream_name = addressee.stream_name()
        if (stream_name is not None):
            ensure_stream(realm, stream_name, acting_user=sender)
    try:
        return check_message(sender, get_client('Internal'), addressee, content, realm=realm)
    except JsonableError as e:
        logging.exception('Error queueing internal message by %s: %s', sender.delivery_email, e.msg)
    return None
Create a message object and checks it, but doesn't send it or save it to the database.
The internal function that calls this can therefore batch send a bunch of created
messages together as one database query.
Call do_send_messages with a list of the return values of this method.
def _internal_prep_message(realm: Realm, sender: UserProfile, addressee: Addressee, content: str) -> Optional[Dict[(str, Any)]]:
    "\n    Create a message object and checks it, but doesn't send it or save it to the database.\n    The internal function that calls this can therefore batch send a bunch of created\n    messages together as one database query.\n    Call do_send_messages with a list of the return values of this method.\n    "
    if (len(content) > MAX_MESSAGE_LENGTH):
        content = (content[0:3900] + '\n\n[message was too long and has been truncated]')
    if addressee.is_stream():
        stream_name = addressee.stream_name()
        if (stream_name is not None):
            ensure_stream(realm, stream_name, acting_user=sender)
    try:
        return check_message(sender, get_client('Internal'), addressee, content, realm=realm)
    except JsonableError as e:
        logging.exception('Error queueing internal message by %s: %s', sender.delivery_email, e.msg)
    return None