1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-23 22:09:22 +00:00
comunicapiv3/src/controllers/friends_controller.rs

20 lines
635 B
Rust
Raw Normal View History

2020-06-29 13:45:26 +00:00
//! # Friends controller
//!
//! @author Pierre Hubert
use crate::api_data::friend_api::FriendAPI;
use crate::controllers::routes::RequestResult;
use crate::data::http_request_handler::HttpRequestHandler;
2020-06-29 13:53:39 +00:00
use crate::helpers::{account_helper, friends_helper};
2020-06-29 13:45:26 +00:00
/// Get the list of friends of the current user
pub fn get_list(r: &mut HttpRequestHandler) -> RequestResult {
let list = friends_helper::get_list(&r.user_id()?)?;
2020-06-29 13:53:39 +00:00
// Update last activity (if allowed)
if !r.post_bool_opt("incognito", false) {
account_helper::update_last_activity(&r.user_id()?)?;
}
2020-06-29 13:45:26 +00:00
r.set_response(FriendAPI::from_list(&list))
}