mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-07-19 21:55:24 +00:00
Get more accurate info
This commit is contained in:
src
@@ -2,7 +2,9 @@
|
||||
//!
|
||||
//! @author Pierre Hubert
|
||||
|
||||
use crate::controllers::user_ws_controller;
|
||||
use crate::data::user::UserID;
|
||||
use crate::utils::date_utils::time;
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
pub struct Friend {
|
||||
@@ -11,4 +13,16 @@ pub struct Friend {
|
||||
pub following: bool,
|
||||
pub last_activity_time: u64,
|
||||
pub can_post_texts: bool,
|
||||
}
|
||||
|
||||
impl Friend {
|
||||
/// Get the last activity of this friend. If this friend is both connected and not incognito,
|
||||
/// current time will be returned instead of time stored in database
|
||||
pub fn computed_last_activity_time(&self) -> u64 {
|
||||
if user_ws_controller::is_user_connected_not_incognito(&self.friend_id) {
|
||||
time()
|
||||
} else {
|
||||
self.last_activity_time
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user