pub fn messages_formatter(
    data: &mut ConversationInfo,
    vec_msg: Vec<Message>,
    interaction_order: i32,
    end: bool,
) -> Map<String, Value> {
    let msgs = vec_msg
        .into_iter()
        .map(|msg| add_info_to_message(data, msg, interaction_order))
        .collect();
    let mut map: Map<String, Value> = Map::new();

    map.insert("messages".to_owned(), Value::Array(msgs));
    map.insert("conversation_end".to_owned(), Value::Bool(end));
    map.insert("request_id".to_owned(), json!(data.request_id));

    map.insert(
        "received_at".to_owned(),
        json!(Utc::now().to_rfc3339_opts(SecondsFormat::Millis, true)),
    );

    let mut map_client: Map<String, Value> = Map::new();

    map_client.insert("bot_id".to_owned(), json!(data.client.bot_id));
    map_client.insert("user_id".to_owned(), json!(data.client.user_id));
    map_client.insert("channel_id".to_owned(), json!(data.client.channel_id));

    map.insert("client".to_owned(), Value::Object(map_client));

    map
}
/**
 * Prepare correctly formatted messages as requested in both:
 * - send action: when callback_url is set, messages are sent as they come to a defined endpoint
 * - return action: at the end of the interaction, all messages are returned as they were processed
 */
Prepare correctly formatted messages as requested in both:
- send action: when callback_url is set, messages are sent as they come to a defined endpoint
- return action: at the end of the interaction, all messages are returned as they were processed
Prepare correctly formatted messages as requested in both : - send action : when callback_url is set messages are sent as they come to a defined endpoint - return action : at the end of the interaction all messages are returned as they were processed
pub fn messages_formatter(
    data: &mut ConversationInfo,
    vec_msg: Vec<Message>,
    interaction_order: i32,
    end: bool,
) -> Map<String, Value> {
    let msgs = vec_msg
        .into_iter()
        .map(|msg| add_info_to_message(data, msg, interaction_order))
        .collect();
    let mut map: Map<String, Value> = Map::new();
    map.insert("messages".to_owned(), Value::Array(msgs));
    map.insert("conversation_end".to_owned(), Value::Bool(end));
    map.insert("request_id".to_owned(), json!(data.request_id));
    map.insert(
        "received_at".to_owned(),
        json!(Utc::now().to_rfc3339_opts(SecondsFormat::Millis, true)),
    );
    let mut map_client: Map<String, Value> = Map::new();
    map_client.insert("bot_id".to_owned(), json!(data.client.bot_id));
    map_client.insert("user_id".to_owned(), json!(data.client.user_id));
    map_client.insert("channel_id".to_owned(), json!(data.client.channel_id));
    map.insert("client".to_owned(), Value::Object(map_client));
    map
}
pub fn messages_formatter ( data : & mut ConversationInfo , vec_msg : Vec < Message > , interaction_order : i32 , end : bool , ) -> Map < String , Value > { let msgs = vec_msg . into_iter ( ) . map ( | msg | add_info_to_message ( data , msg , interaction_order ) ) . collect ( ) ; let mut map : Map < String , Value > = Map :: new ( ) ; map . insert ( " " . to_owned ( ) , Value :: Array ( msgs ) ) ; map . insert ( " " . to_owned ( ) , Value :: Bool ( end ) ) ; map . insert ( " " . to_owned ( ) , json ! ( data request_id ) ) ; map . insert ( " " . to_owned ( ) , json ! ( Utc now ( ) to_rfc3339_opts ( SecondsFormat Millis true ) ) , ) ; let mut map_client : Map < String , Value > = Map :: new ( ) ; map_client . insert ( " " . to_owned ( ) , json ! ( data client bot_id ) ) ; map_client . insert ( " " . to_owned ( ) , json ! ( data client user_id ) ) ; map_client . insert ( " " . to_owned ( ) , json ! ( data client channel_id ) ) ; map . insert ( " " . to_owned ( ) , Value :: Object ( map_client ) ) ; map }
Prepare correctly formatted messages as requested in both:
 - send action: when callback_url is set, messages are sent as they come to a defined endpoint
 - return action: at the end of the interaction, all messages are returned as they were processed
Prepare correctly formatted messages as requested in both : - send action : when callback_url is set messages are sent as they come to a defined endpoint - return action : at the end of the interaction all messages are returned as they were processed
data
&mut ConversationInfo
vec_msg
Vec<Message>
interaction_order
i32
end
bool
data
&mut ConversationInfo
vec_msg
Vec<Message>
interaction_order
i32
end
bool