diff --git a/src/controllers/likes_controller.rs b/src/controllers/likes_controller.rs index f37aa8b..c3e8082 100644 --- a/src/controllers/likes_controller.rs +++ b/src/controllers/likes_controller.rs @@ -7,7 +7,7 @@ use crate::data::error::ExecError; use crate::data::group::GroupAccessLevel; use crate::data::http_request_handler::HttpRequestHandler; use crate::data::post::PostAccessLevel; -use crate::helpers::{likes_helper, user_helper}; +use crate::helpers::{likes_helper, notifications_helper, user_helper}; use crate::helpers::likes_helper::LikeType; struct LikeTarget(u64, LikeType); @@ -35,7 +35,8 @@ pub fn update(r: &mut HttpRequestHandler) -> RequestResult { "post" => { let post = r.post_post_with_access("id", PostAccessLevel::BASIC_ACCESS)?; - // TODO : delete any notification targeting this user about the post + // Delete any notification targeting this user about the post + notifications_helper::delete_all_post_notifications_targeting_user(r.user_id_ref()?, post.id)?; LikeTarget(post.id, LikeType::POST) } @@ -43,6 +44,10 @@ pub fn update(r: &mut HttpRequestHandler) -> RequestResult { // In case of comment "comment" => { let comment = r.post_comment_with_access("id")?; + + // Delete any notification targeting this user about the post + notifications_helper::delete_all_post_notifications_targeting_user(r.user_id_ref()?, comment.post_id)?; + LikeTarget(comment.id, LikeType::COMMENT) }