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

Can get the status of a friendship

This commit is contained in:
2020-06-30 09:50:31 +02:00
parent 31ed53aacf
commit 91d12bb061
7 changed files with 102 additions and 2 deletions

View File

@ -3,6 +3,7 @@
//! @author Pierre Hubert
use crate::api_data::friend_api::FriendAPI;
use crate::api_data::friendship_status_api::FriendshipStatusAPI;
use crate::controllers::routes::RequestResult;
use crate::data::http_request_handler::HttpRequestHandler;
use crate::helpers::{account_helper, friends_helper, user_helper};
@ -49,4 +50,14 @@ pub fn get_other_user_list(r: &mut HttpRequestHandler) -> RequestResult {
let friends = friends_helper::GetFriendsQuery::new(&user_id).exec()?;
r.set_response(friends.iter().map(|f| f.friend_id.id()).collect::<Vec<u64>>())
}
/// Get the status of a friendship
pub fn get_status(r: &mut HttpRequestHandler) -> RequestResult {
let friend_id = r.post_user_id("friendID")?;
let curr_user_id = r.user_id()?;
let status = friends_helper::get_status(&curr_user_id, &friend_id)?;
r.set_response(FriendshipStatusAPI::new(&status))
}

View File

@ -95,6 +95,8 @@ pub fn get_routes() -> Vec<Route> {
Route::post("/friends/get_user_list", Box::new(friends_controller::get_other_user_list)),
Route::post("/friends/getStatus", Box::new(friends_controller::get_status)),
// Conversations controller
Route::post("/conversations/create", Box::new(conversations_controller::create)),