1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-06-20 16:35:17 +00:00

Can change the visibility level of a post

This commit is contained in:
2020-07-09 09:10:42 +02:00
parent 4a559f8222
commit dc5ad6aea4
4 changed files with 33 additions and 1 deletions

View File

@ -383,6 +383,14 @@ pub fn allow_comments_on_post(p: &Post) -> ResultBoxError<bool> {
user_helper::allow_comments(p.user_page_id().unwrap_or(&UserID::invalid()))?)
}
/// Set a new visibility level to a post
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())
.exec()
}
/// Turn a post into a database entry
fn db_to_post(res: &database::RowResult) -> ResultBoxError<Post> {
let user_id = if res.get_u64("ID_amis")? == 0 {