1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-06-21 00:45:18 +00:00

Can open new conversations

This commit is contained in:
2020-06-18 14:15:17 +02:00
parent 479caa3945
commit e7de23e995
8 changed files with 156 additions and 4 deletions

View File

@ -2,7 +2,10 @@
//!
//! @author Pierre Hubert
use std::collections::HashMap;
use crate::api_data::conversation_api::ConversationAPI;
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;
use crate::controllers::routes::RequestResult;
@ -160,5 +163,24 @@ pub fn find_private(r: &mut HttpRequestHandler) -> RequestResult {
///
/// This method was used only by ComunicWeb before the introduction of WebSockets
pub fn refresh_list(r: &mut HttpRequestHandler) -> RequestResult {
r.success("Can implement")
let mut list = HashMap::new();
// Check for new conversations
if r.has_post_parameter("newConversations") {
for conv_id in r.post_numbers_list("newConversations", 0)? {
if !conversations_helper::does_user_belongs_to(r.user_id()?, conv_id as u64)? {
r.forbidden(format!("Your do not belongs to conversation {} !", conv_id))?;
}
let msgs_conv = conversations_helper::get_last_messages(conv_id as u64, 10)?;
list.insert(conv_id as u64, msgs_conv);
//TODO : mark user seen
}
// TODO : Check for refresh of already initialized conversations
}
r.set_response(ConversationRefreshResultAPI::new(list))
}