Can update client last usage
This commit is contained in:
11
src/user.rs
11
src/user.rs
@@ -80,6 +80,10 @@ impl APIClient {
|
||||
pub fn fmt_used(&self) -> String {
|
||||
format_time(self.used).unwrap_or_default()
|
||||
}
|
||||
|
||||
pub fn need_update_last_used(&self) -> bool {
|
||||
self.used + 60 * 15 < curr_time().unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl APIClient {
|
||||
@@ -97,7 +101,7 @@ impl APIClient {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
#[derive(serde::Serialize, serde::Deserialize, Clone)]
|
||||
pub struct UserConfig {
|
||||
/// Target user ID
|
||||
pub user_id: UserID,
|
||||
@@ -211,4 +215,9 @@ impl UserConfig {
|
||||
pub fn find_client_by_id(&self, id: &APIClientID) -> Option<&APIClient> {
|
||||
self.clients.iter().find(|c| &c.id == id)
|
||||
}
|
||||
|
||||
/// Find a client by its id and get a mutable reference
|
||||
pub fn find_client_by_id_mut(&mut self, id: &APIClientID) -> Option<&mut APIClient> {
|
||||
self.clients.iter_mut().find(|c| &c.id == id)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user