mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-12-27 22:18:51 +00:00
Update last activity of the user
This commit is contained in:
parent
3af2a6f58d
commit
8c424bcec4
@ -1,8 +1,8 @@
|
||||
use crate::api_data::current_user_id::CurrentUserID;
|
||||
use crate::api_data::login_success::LoginSuccess;
|
||||
use crate::controllers::routes::RequestResult;
|
||||
use crate::data::http_request_handler::HttpRequestHandler;
|
||||
use crate::helpers::account_helper;
|
||||
use crate::api_data::current_user_id::CurrentUserID;
|
||||
|
||||
/// Account controller
|
||||
///
|
||||
@ -35,7 +35,7 @@ pub fn login_user(request: &mut HttpRequestHandler) -> RequestResult {
|
||||
pub fn logout_user(request: &mut HttpRequestHandler) -> RequestResult {
|
||||
account_helper::destroy_login_tokens(
|
||||
&request.user_id()?,
|
||||
request.api_client()
|
||||
request.api_client(),
|
||||
)?;
|
||||
|
||||
request.success("User disconnected.")
|
||||
|
@ -5,13 +5,16 @@
|
||||
use crate::api_data::friend_api::FriendAPI;
|
||||
use crate::controllers::routes::RequestResult;
|
||||
use crate::data::http_request_handler::HttpRequestHandler;
|
||||
use crate::helpers::friends_helper;
|
||||
use crate::helpers::{account_helper, friends_helper};
|
||||
|
||||
/// 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()?)?;
|
||||
|
||||
// TODO : update last activity (if allowed)
|
||||
// Update last activity (if allowed)
|
||||
if !r.post_bool_opt("incognito", false) {
|
||||
account_helper::update_last_activity(&r.user_id()?)?;
|
||||
}
|
||||
|
||||
r.set_response(FriendAPI::from_list(&list))
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
use crate::constants::database_tables_names::USER_ACCESS_TOKENS_TABLE;
|
||||
use crate::constants::database_tables_names::{USER_ACCESS_TOKENS_TABLE, USERS_TABLE};
|
||||
use crate::data::api_client::APIClient;
|
||||
use crate::data::error::{ExecError, ResultBoxError};
|
||||
use crate::data::user::UserID;
|
||||
@ -6,6 +6,7 @@ use crate::data::user_token::UserAccessToken;
|
||||
use crate::helpers::{database, user_helper};
|
||||
use crate::helpers::database::{DeleteQuery, InsertQuery, QueryInfo};
|
||||
use crate::utils::crypt_utils::{crypt_pass, rand_str};
|
||||
use crate::utils::date_utils::time;
|
||||
|
||||
/// Account helper
|
||||
///
|
||||
@ -101,4 +102,12 @@ pub fn check_user_directory_availability(dir: &str, user_id: Option<UserID>) ->
|
||||
// No user was found, virtual directory is considered as available
|
||||
(Err(_), _) => Ok(true)
|
||||
}
|
||||
}
|
||||
|
||||
/// Update the last activity of a user
|
||||
pub fn update_last_activity(user_id: &UserID) -> ResultBoxError {
|
||||
database::UpdateInfo::new(USERS_TABLE)
|
||||
.cond_user_id("ID", user_id)
|
||||
.set_u64("last_activity", time())
|
||||
.exec()
|
||||
}
|
Loading…
Reference in New Issue
Block a user