1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-26 07:19:22 +00:00

Update can_post_texts parameter

This commit is contained in:
Pierre HUBERT 2020-06-30 14:54:45 +02:00
parent b15ffe0856
commit d195979c18
3 changed files with 21 additions and 0 deletions

View File

@ -138,3 +138,13 @@ pub fn set_following(r: &mut HttpRequestHandler) -> RequestResult {
r.success("Following status updated!")
}
/// Update post texts authorization status
pub fn set_can_post_texts(r: &mut HttpRequestHandler) -> RequestResult {
let friend_id = r.post_friend_id("friendID")?;
let allow = r.post_bool("allow")?;
friends_helper::set_can_post_texts(r.user_id_ref()?, &friend_id, allow)?;
r.success("Updated status!")
}

View File

@ -107,6 +107,8 @@ pub fn get_routes() -> Vec<Route> {
Route::post("/friends/setFollowing", Box::new(friends_controller::set_following)),
Route::post("/friends/set_can_post_texts", Box::new(friends_controller::set_can_post_texts)),
// Conversations controller
Route::post("/conversations/create", Box::new(conversations_controller::create)),

View File

@ -172,6 +172,15 @@ pub fn set_following(user_id: &UserID, friend_id: &UserID, follow: bool) -> Resu
.exec()
}
/// Specify whether a friend is allowed to create posts on current user's page or not
pub fn set_can_post_texts(user_id: &UserID, friend_id: &UserID, allow: bool) -> ResultBoxError {
database::UpdateInfo::new(FRIENDS_TABLE)
.cond_user_id("ID_personne", user_id)
.cond_user_id("ID_amis", friend_id)
.set_legacy_bool("autoriser_post_page", allow)
.exec()
}
/// Get the status of a friendship
pub fn get_status(user_id: &UserID, friend_id: &UserID) -> ResultBoxError<FriendshipStatus> {
let mut status = FriendshipStatus {