1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-06-20 16:35:17 +00:00

Count the number of unread conversations of a user

This commit is contained in:
2020-06-22 14:32:14 +02:00
parent f8934d4e0a
commit b9a8dce1a5
6 changed files with 49 additions and 1 deletions

View File

@ -15,6 +15,7 @@ use crate::data::new_conversation::NewConversation;
use crate::data::new_conversation_message::NewConversationMessage;
use crate::helpers::{conversations_helper, user_helper};
use crate::utils::string_utils::remove_html_nodes;
use crate::api_data::res_count_unread_conversations::ResultCountUnreadConversations;
/// Create a new conversation
pub fn create(r: &mut HttpRequestHandler) -> RequestResult {
@ -273,4 +274,11 @@ pub fn send_message(r: &mut HttpRequestHandler) -> RequestResult {
})?;
r.success("Conversation message was successfully sent!")
}
/// Count the number of unread conversation of the user
pub fn count_unread(r: &mut HttpRequestHandler) -> RequestResult {
let num = conversations_helper::count_unread_for_user(r.user_id()?)?;
r.set_response(ResultCountUnreadConversations::new(num))
}

View File

@ -108,6 +108,8 @@ pub fn get_routes() -> Vec<Route> {
Route::post("/conversations/sendMessage", Box::new(conversations_controller::send_message)),
Route::post("/conversations/get_number_unread", Box::new(conversations_controller::count_unread)),
// Virtual directory controller
Route::post("/user/findbyfolder", Box::new(virtual_directory_controller::find_user)),