diff --git a/src/controllers/comments_controller.rs b/src/controllers/comments_controller.rs index 8e76a90..1eb9863 100644 --- a/src/controllers/comments_controller.rs +++ b/src/controllers/comments_controller.rs @@ -49,7 +49,8 @@ pub fn create(r: &mut HttpRequestHandler) -> RequestResult { // Create notifications notifications_helper::create_post_notification(&r.user_id()?, post.id, NotifEventType::COMMENT_CREATED)?; - // TODO : Remove notifications targeting current user about the post + // Remove notifications targeting current user about the post + notifications_helper::delete_all_post_notifications_targeting_user(r.user_id_ref()?, post.id)?; r.set_response(ResCreateComment::new(comment_id)) } diff --git a/src/helpers/notifications_helper.rs b/src/helpers/notifications_helper.rs index 1a9d30b..633dd42 100644 --- a/src/helpers/notifications_helper.rs +++ b/src/helpers/notifications_helper.rs @@ -285,6 +285,16 @@ pub fn delete_all_related_to_group_membership_notifications(user_id: &UserID, gr Ok(()) } +/// Delete all the notifications about a post targeting a specified user +pub fn delete_all_post_notifications_targeting_user(user_id: &UserID, post_id: PostID) -> ResultBoxError { + let n = PartialNotification::new() + .set_dest_user_id(user_id) + .set_on_elem_type(NotifElemType::POST) + .set_on_elem_id(post_id); + + delete(&n) +} + /// Delete all the notifications related with a post pub fn delete_all_related_with_post(post_id: PostID) -> ResultBoxError { let n = PartialNotification::new()