[Mig] storage to SQLite pool

[Clean] split message handler dispatch
This commit is contained in:
Alex Emmet 2026-07-08 23:40:46 +02:00
commit 3be1d9f308
18 changed files with 1949 additions and 1700 deletions

View file

@ -1,4 +1,3 @@
use json::{self, JsonValue, number::Number};
use std::time::{SystemTime, UNIX_EPOCH};
#[derive(Debug, Clone)]
@ -33,29 +32,4 @@ impl Contact {
pub fn set_last_message_at(&mut self, p0: i64) {
self.last_message_at = Option::from(p0);
}
pub fn to_json(&self) -> JsonValue {
let mut obj = JsonValue::new_object();
obj["user_id"] = JsonValue::Number(Number::from(self.user_id));
if let Some(name) = &self.user_name {
obj["user_name"] = JsonValue::from(name.as_str());
}
if let Some(ts) = &self.last_message_at {
obj["last_message_at"] = JsonValue::Number(Number::from(*ts));
}
obj
}
pub fn from_json(o: &JsonValue) -> Contact {
let user_id = o["user_id"].as_i64().unwrap_or(0);
let user_name = o["user_name"].as_str().map(|s| s.to_string());
let last_message_at = o["last_message_at"].as_i64();
Contact {
user_id,
user_name,
last_message_at,
}
}
}