mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-12-27 22:18:51 +00:00
/notifications/mark_seen is fully implemented
This commit is contained in:
parent
b133827c61
commit
2fc6b83f77
@ -8,7 +8,7 @@ use crate::api_data::res_number_unread_notifications::ResNumberUnreadNotificatio
|
||||
use crate::controllers::routes::RequestResult;
|
||||
use crate::data::error::ResultBoxError;
|
||||
use crate::data::http_request_handler::HttpRequestHandler;
|
||||
use crate::data::notification::{Notification, PartialNotification};
|
||||
use crate::data::notification::Notification;
|
||||
use crate::helpers::{conversations_helper, friends_helper, notifications_helper};
|
||||
|
||||
impl HttpRequestHandler {
|
||||
@ -59,17 +59,15 @@ pub fn mark_seen(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
let notif = r.post_notif_id("notifID")?;
|
||||
let delete_similar = r.post_bool_opt("delete_similar", false);
|
||||
|
||||
let mut notif = notif.into_partial();
|
||||
|
||||
// Check if we are targeting a precise notification or an undetermined number of similar
|
||||
// notifications
|
||||
if !delete_similar {
|
||||
notifications_helper::delete(
|
||||
&PartialNotification::new()
|
||||
.set_id(notif.id)
|
||||
)?;
|
||||
} else {
|
||||
// TODO : implement me
|
||||
unimplemented!();
|
||||
if delete_similar {
|
||||
notif.id = None;
|
||||
}
|
||||
|
||||
notifications_helper::delete(¬if)?;
|
||||
|
||||
r.success("Notification deleted")
|
||||
}
|
@ -153,6 +153,24 @@ pub struct Notification {
|
||||
pub container_type: Option<NotifElemType>,
|
||||
}
|
||||
|
||||
impl Notification {
|
||||
pub fn into_partial(self) -> PartialNotification {
|
||||
PartialNotification {
|
||||
id: Some(self.id),
|
||||
time_create: Some(self.time_create),
|
||||
seen: Some(self.seen),
|
||||
from_user_id: Some(self.from_user_id),
|
||||
dest_user_id: Some(self.dest_user_id),
|
||||
on_elem_id: Some(self.on_elem_id),
|
||||
on_elem_type: Some(self.on_elem_type),
|
||||
kind: Some(self.kind),
|
||||
visibility: Some(self.visibility),
|
||||
container_id: self.container_id,
|
||||
container_type: self.container_type,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct PartialNotification {
|
||||
pub id: Option<u64>,
|
||||
pub time_create: Option<u64>,
|
||||
|
Loading…
Reference in New Issue
Block a user