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:
@ -114,7 +114,7 @@ pub fn create_post(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
time_create: time(),
|
||||
target_page,
|
||||
content: Some(r.post_string_opt("content", 0, false)?),
|
||||
visibility: PostVisibilityLevel::VISIBILITY_PUBLIC,
|
||||
visibility: PostVisibilityLevel::VISIBILITY_PUBLIC, // TODO : fix
|
||||
kind: PostKind::POST_KIND_TEXT,
|
||||
};
|
||||
|
||||
@ -235,4 +235,16 @@ pub fn create_post(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
|
||||
// TODO : create a notification
|
||||
r.set_response(ResCreatePost::new(post_id))
|
||||
}
|
||||
|
||||
/// Change the visibility level of a post
|
||||
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)?;
|
||||
|
||||
// TODO : Depending on new level, delete (or not) notifications about the post
|
||||
|
||||
r.success("Visibility level updated")
|
||||
}
|
@ -208,6 +208,8 @@ pub fn get_routes() -> Vec<Route> {
|
||||
|
||||
Route::post("/posts/create", Box::new(posts_controller::create_post)),
|
||||
|
||||
Route::post("/posts/set_visibility_level", Box::new(posts_controller::set_visibility_level)),
|
||||
|
||||
|
||||
// Movies controller
|
||||
Route::post("/movies/get_list", Box::new(movies_controller::get_list)),
|
||||
|
Reference in New Issue
Block a user