mirror of
				https://gitlab.com/comunic/comunicapiv3
				synced 2025-11-04 09:34:04 +00:00 
			
		
		
		
	Delete notifications on like updates
This commit is contained in:
		@@ -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)
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user