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

Can count the number of unread notifications

This commit is contained in:
2020-07-10 12:55:50 +02:00
parent 6b0363935e
commit 32aa7e7d1e
8 changed files with 58 additions and 3 deletions

View File

@ -12,5 +12,6 @@ pub mod posts_controller;
pub mod comments_controller;
pub mod likes_controller;
pub mod surveys_controller;
pub mod notifications_controller;
pub mod movies_controller;
pub mod virtual_directory_controller;

View File

@ -0,0 +1,14 @@
//! # Notifications controller
//!
//! @author Pierre Hubert
use crate::api_data::res_number_unread_notifications::ResNumberUnreadNotifications;
use crate::controllers::routes::RequestResult;
use crate::data::http_request_handler::HttpRequestHandler;
use crate::helpers::notifications_helper;
/// Count the number of unread notifications
pub fn count_unread(r: &mut HttpRequestHandler) -> RequestResult {
let number = notifications_helper::count_unread(r.user_id_ref()?)?;
r.set_response(ResNumberUnreadNotifications::new(number))
}

View File

@ -1,6 +1,6 @@
use std::error::Error;
use crate::controllers::{account_controller, comments_controller, conversations_controller, friends_controller, groups_controller, likes_controller, movies_controller, posts_controller, search_controller, server_controller, surveys_controller, user_controller, virtual_directory_controller};
use crate::controllers::{account_controller, comments_controller, conversations_controller, friends_controller, groups_controller, likes_controller, movies_controller, notifications_controller, posts_controller, search_controller, server_controller, surveys_controller, user_controller, virtual_directory_controller};
use crate::controllers::routes::Method::{GET, POST};
use crate::data::http_request_handler::HttpRequestHandler;
@ -244,6 +244,8 @@ pub fn get_routes() -> Vec<Route> {
Route::post("/surveys/block_new_choices_creation", Box::new(surveys_controller::block_new_choices_creation)),
// Notifications controller
Route::post("/notifications/count_unread", Box::new(notifications_controller::count_unread)),
// Movies controller
Route::post("/movies/get_list", Box::new(movies_controller::get_list)),