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

Start to implement the mark_seen method

This commit is contained in:
2020-07-11 13:29:12 +02:00
parent 87718076e7
commit 7519ce59fc
5 changed files with 159 additions and 12 deletions

View File

@ -6,9 +6,28 @@ use crate::api_data::notification_api::NotificationAPI;
use crate::api_data::res_count_all_unreads::ResCountAllUnread;
use crate::api_data::res_number_unread_notifications::ResNumberUnreadNotifications;
use crate::controllers::routes::RequestResult;
use crate::data::error::ResultBoxError;
use crate::data::http_request_handler::HttpRequestHandler;
use crate::data::notification::PartialNotification;
use crate::helpers::{conversations_helper, friends_helper, notifications_helper};
impl HttpRequestHandler {
/// Get the id of a notification included in the request
pub fn post_notif_id(&mut self, name: &str) -> ResultBoxError<u64> {
let notif_id = self.post_u64(name)?;
let notif = PartialNotification::new()
.set_id(notif_id)
.set_dest_user_id(self.user_id_ref()?);
if !notifications_helper::similar_exists(&notif)? {
self.not_found("Specified notification not found!".to_string())?;
}
Ok(notif_id)
}
}
/// Count the number of unread notifications
pub fn count_unread(r: &mut HttpRequestHandler) -> RequestResult {
let number = notifications_helper::count_unread(r.user_id_ref()?)?;
@ -32,4 +51,13 @@ pub fn get_list_unread(r: &mut HttpRequestHandler) -> RequestResult {
let list = notifications_helper::get_list_unread(r.user_id_ref()?)?;
r.set_response(NotificationAPI::for_list(&list))
}
/// Mark a notification as seen
pub fn mark_seen(r: &mut HttpRequestHandler) -> RequestResult {
let notif_id = r.post_notif_id("notifID")?;
let delete_similar = r.post_bool_opt("delete_similar", false);
// TODO : continue implementation
r.success("continue implementation")
}

View File

@ -251,6 +251,8 @@ pub fn get_routes() -> Vec<Route> {
Route::post("/notifications/get_list_unread", Box::new(notifications_controller::get_list_unread)),
Route::post("/notifications/mark_seen", Box::new(notifications_controller::mark_seen)),
// Movies controller
Route::post("/movies/get_list", Box::new(movies_controller::get_list)),