[Fix] Durability
This commit is contained in:
parent
dd69b5bd97
commit
ec3f5e6a6e
9 changed files with 317 additions and 118 deletions
|
|
@ -1,31 +1,32 @@
|
|||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Contact {
|
||||
pub user_id: i64,
|
||||
pub user_name: Option<String>,
|
||||
pub created_at: i64,
|
||||
pub last_message_at: Option<i64>,
|
||||
}
|
||||
|
||||
impl Default for Contact {
|
||||
fn default() -> Self {
|
||||
let now = SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_millis() as i64;
|
||||
Contact {
|
||||
user_id: 0,
|
||||
user_name: None,
|
||||
last_message_at: Some(now),
|
||||
created_at: 0,
|
||||
last_message_at: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Contact {
|
||||
pub fn new(user_id: i64) -> Self {
|
||||
let created_at = std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
.unwrap_or_default()
|
||||
.as_millis() as i64;
|
||||
Contact {
|
||||
user_id: user_id,
|
||||
user_name: None,
|
||||
created_at,
|
||||
last_message_at: None,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue