mirror of
				https://gitlab.com/comunic/comunicapiv3
				synced 2025-11-04 09:34:04 +00:00 
			
		
		
		
	Can delete all the notifications related with a user
This commit is contained in:
		@@ -216,6 +216,11 @@ impl PartialNotification {
 | 
			
		||||
        self
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub fn set_from_user_id(mut self, id: &UserID) -> PartialNotification {
 | 
			
		||||
        self.from_user_id = Some(id.clone());
 | 
			
		||||
        self
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub fn set_on_elem_id(mut self, id: u64) -> PartialNotification {
 | 
			
		||||
        self.on_elem_id = Some(id);
 | 
			
		||||
        self
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@ use crate::data::new_account::NewAccount;
 | 
			
		||||
use crate::data::security_settings::SecuritySettings;
 | 
			
		||||
use crate::data::user::{AccountImageVisibility, UserID, UserPageStatus};
 | 
			
		||||
use crate::data::user_token::UserAccessToken;
 | 
			
		||||
use crate::helpers::{comments_helper, conversations_helper, database, friends_helper, groups_helper, likes_helper, movies_helper, posts_helper, survey_helper, user_helper};
 | 
			
		||||
use crate::helpers::{comments_helper, conversations_helper, database, friends_helper, groups_helper, likes_helper, movies_helper, notifications_helper, posts_helper, survey_helper, user_helper};
 | 
			
		||||
use crate::helpers::database::{DeleteQuery, InsertQuery, QueryInfo};
 | 
			
		||||
use crate::utils::crypt_utils::{crypt_pass, rand_str};
 | 
			
		||||
use crate::utils::date_utils::{mysql_date, time};
 | 
			
		||||
@@ -327,6 +327,9 @@ pub fn delete(user_id: &UserID) -> ResultBoxError {
 | 
			
		||||
    // Remove the user from all its conversations
 | 
			
		||||
    conversations_helper::delete_all_user_conversations(user_id)?;
 | 
			
		||||
 | 
			
		||||
    // Delete all the notifications related with the user
 | 
			
		||||
    notifications_helper::delete_all_related_with_user(user_id)?;
 | 
			
		||||
 | 
			
		||||
    // TODO : continue work here
 | 
			
		||||
 | 
			
		||||
    Ok(())
 | 
			
		||||
 
 | 
			
		||||
@@ -27,6 +27,17 @@ pub fn delete_all_user(user_id: &UserID) -> ResultBoxError {
 | 
			
		||||
    delete(&PartialNotification::new().set_dest_user_id(user_id))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Delete all the notifications related with a user
 | 
			
		||||
pub fn delete_all_related_with_user(user_id: &UserID) -> ResultBoxError {
 | 
			
		||||
    // Delete all the notifications targeting the user
 | 
			
		||||
    delete_all_user(user_id)?;
 | 
			
		||||
 | 
			
		||||
    // Delete all the notifications created by the user
 | 
			
		||||
    delete(&PartialNotification::new().set_from_user_id(user_id))?;
 | 
			
		||||
 | 
			
		||||
    Ok(())
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Delete all the notifications related with a group
 | 
			
		||||
pub fn delete_all_related_with_group(group_id: &GroupID) -> ResultBoxError {
 | 
			
		||||
    delete(&PartialNotification::new()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user