def apply_formatting(msg_obj, formatter):
    """
    Receives a messages object from a thread and returns it with
    all the message bodies passed through FORMATTER. Not all
    formatting functions have to return a string. Refer to the
    documentation for each formatter.
    """
    for x, obj in enumerate(msg_obj):
        if not msg_obj[x].get("send_raw"):
            msg_obj[x]["body"] = formatter(obj["body"])
    return msg_obj