1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-12-27 22:18:51 +00:00

Delete notifications on like updates

This commit is contained in:
Pierre HUBERT 2021-01-24 18:09:45 +01:00
parent 334496a63c
commit 3afc30fb89

View File

@ -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)
}