mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-26 15:29:21 +00:00
Delete all notifications about a post when making it private
This commit is contained in:
parent
608a85e7f5
commit
c510e6abce
@ -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 post = r.post_post_with_access("postID", PostAccessLevel::FULL_ACCESS)?;
|
||||||
let new_visibility = PostVisibilityLevel::from_api(&r.post_string("new_level")?);
|
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")
|
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
|
/// 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)
|
database::UpdateInfo::new(POSTS_TABLE)
|
||||||
.cond_u64("ID", post_id)
|
.cond_u64("ID", post_id)
|
||||||
.set_u32("niveau_visibilite", level.to_db())
|
.set_u32("niveau_visibilite", level.to_db())
|
||||||
|
Loading…
Reference in New Issue
Block a user