1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-27 07:49:21 +00:00
comunicapiv3/src/api_data/conversations_refresh_api.rs

38 lines
965 B
Rust

//! # Conversation refresh result
//!
//! Note : this structure is now deprecated and should no longer be used for further developments
//!
//! @author Pierre Hubert
use std::collections::HashMap;
use serde::Serialize;
use crate::api_data::conversation_message_api::ConversationMessageAPI;
use crate::data::conversation_message::ConversationMessage;
#[derive(Serialize)]
#[allow(non_snake_case)]
pub struct ConversationRefreshResultAPI {
#[serde(flatten)]
list: HashMap<String, Vec<ConversationMessageAPI>>,
}
impl ConversationRefreshResultAPI {
/// Create a new list
pub fn new(list: HashMap<u64, Vec<ConversationMessage>>) -> ConversationRefreshResultAPI {
let list = list
.iter()
.map(|v| (
format!("conversation-{}", v.0),
ConversationMessageAPI::for_list(v.1)
))
.collect();
ConversationRefreshResultAPI {
list
}
}
}