mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-26 07:19:22 +00:00
Can get the messages of a single conversation
This commit is contained in:
parent
0254b6b614
commit
c551c2d764
@ -5,6 +5,7 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::api_data::conversation_api::ConversationAPI;
|
||||
use crate::api_data::conversation_message_api::ConversationMessageAPI;
|
||||
use crate::api_data::conversations_refresh_api::ConversationRefreshResultAPI;
|
||||
use crate::api_data::res_create_conversation::ResCreateConversation;
|
||||
use crate::api_data::res_find_private_conversations::ResFindPrivateConversations;
|
||||
@ -214,5 +215,18 @@ pub fn refresh_list(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
|
||||
/// Refresh a single conversation
|
||||
pub fn refresh_single(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
r.success("implement it")
|
||||
let conv_id = r.post_conv_id("conversationID")?;
|
||||
let last_message_id = r.post_u64("last_message_id")?;
|
||||
|
||||
let messages = match last_message_id {
|
||||
// Get latest messages of the conversation
|
||||
0 => conversations_helper::get_last_messages(conv_id, 10)?,
|
||||
|
||||
// Get new messages
|
||||
_ => conversations_helper::get_new_messages(conv_id, last_message_id)?,
|
||||
};
|
||||
|
||||
conversations_helper::mark_user_seen(conv_id, r.user_id()?)?;
|
||||
|
||||
r.set_response(ConversationMessageAPI::for_list(&messages))
|
||||
}
|
Loading…
Reference in New Issue
Block a user