mirror of
				https://gitlab.com/comunic/comunicapiv3
				synced 2025-10-31 07:34:45 +00:00 
			
		
		
		
	Delete all notifications about a post when making it private
This commit is contained in:
		| @@ -246,9 +246,12 @@ pub fn set_visibility_level(r: &mut HttpRequestHandler) -> RequestResult { | ||||
|     let post = r.post_post_with_access("postID", PostAccessLevel::FULL_ACCESS)?; | ||||
|     let new_visibility = PostVisibilityLevel::from_api(&r.post_string("new_level")?); | ||||
|  | ||||
|     posts_helper::set_level(post.id, new_visibility)?; | ||||
|     posts_helper::set_level(post.id, &new_visibility)?; | ||||
|  | ||||
|     // TODO : Depending on new level, delete (or not) notifications about the post | ||||
|     // Depending on new level, delete (or not) notifications about the post | ||||
|     if matches!(new_visibility, PostVisibilityLevel::VISIBILITY_USER) { | ||||
|         notifications_helper::delete_all_related_with_post(post.id)?; | ||||
|     } | ||||
|  | ||||
|     r.success("Visibility level updated") | ||||
| } | ||||
|   | ||||
| @@ -403,7 +403,7 @@ pub fn allow_comments_on_post(p: &Post) -> ResultBoxError<bool> { | ||||
| } | ||||
|  | ||||
| /// Set a new visibility level to a post | ||||
| pub fn set_level(post_id: u64, level: PostVisibilityLevel) -> ResultBoxError { | ||||
| pub fn set_level(post_id: u64, level: &PostVisibilityLevel) -> ResultBoxError { | ||||
|     database::UpdateInfo::new(POSTS_TABLE) | ||||
|         .cond_u64("ID", post_id) | ||||
|         .set_u32("niveau_visibilite", level.to_db()) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user