Use depot to ensure Cookie value is acquired, switch to chrono for datetime serialization

This commit is contained in:
2024-12-22 23:03:42 -06:00
parent 5cdee5fb93
commit 54ddf4496c
4 changed files with 105 additions and 20 deletions

View File

@@ -9,10 +9,8 @@ use crate::utility::search;
#[derive(Clone, Debug, Serialize)]
pub struct Session {
pub tokens: Vec<String>,
#[serde(skip_serializing)]
pub last_seen: std::time::Instant,
#[serde(skip_serializing)]
pub first_seen: std::time::Instant,
pub last_seen: chrono::DateTime<chrono::Utc>,
pub first_seen: chrono::DateTime<chrono::Utc>,
}
#[derive(Default, Clone, Debug)]
@@ -56,12 +54,13 @@ impl<'a> State<'a> {
let mut rng = rand::thread_rng();
let id: usize = rng.gen();
let now = chrono::Utc::now();
self.sessions.insert(
id,
Session {
tokens: vec![],
last_seen: std::time::Instant::now(),
first_seen: std::time::Instant::now(),
last_seen: now,
first_seen: now,
},
);