mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-06-21 00:45:18 +00:00
Get the list of unread conversations
This commit is contained in:
33
src/api_data/list_unread_conversations_api.rs
Normal file
33
src/api_data/list_unread_conversations_api.rs
Normal file
@ -0,0 +1,33 @@
|
||||
//! # List of unread conversations
|
||||
use serde::{Serialize};
|
||||
use crate::data::unread_conversation::UnreadConversation;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[allow(non_snake_case)]
|
||||
pub struct UnreadConversationAPI {
|
||||
id: u64,
|
||||
conv_name: String,
|
||||
last_active: u64,
|
||||
userID: u64,
|
||||
message: String
|
||||
}
|
||||
|
||||
impl UnreadConversationAPI {
|
||||
/// Construct a new instance
|
||||
pub fn new(conv: &UnreadConversation) -> UnreadConversationAPI {
|
||||
UnreadConversationAPI {
|
||||
id: conv.id,
|
||||
conv_name: conv.name.clone().unwrap_or(String::new()),
|
||||
last_active: conv.last_active,
|
||||
userID: conv.user_id as u64,
|
||||
message: conv.message.clone()
|
||||
}
|
||||
}
|
||||
|
||||
/// Turn a list of unread conversation into API conversations
|
||||
pub fn for_list(l: &Vec<UnreadConversation>) -> Vec<UnreadConversationAPI> {
|
||||
l.iter()
|
||||
.map(|row| Self::new(row))
|
||||
.collect()
|
||||
}
|
||||
}
|
@ -20,4 +20,5 @@ mod legacy_api_bool;
|
||||
pub mod res_find_private_conversations;
|
||||
pub mod conversation_message_api;
|
||||
pub mod conversations_refresh_api;
|
||||
pub mod res_count_unread_conversations;
|
||||
pub mod res_count_unread_conversations;
|
||||
pub mod list_unread_conversations_api;
|
Reference in New Issue
Block a user