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:
@ -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;
|
||||
|
14
src/controllers/notifications_controller.rs
Normal file
14
src/controllers/notifications_controller.rs
Normal 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))
|
||||
}
|
@ -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)),
|
||||
|
Reference in New Issue
Block a user