diff --git a/Cargo.lock b/Cargo.lock index 2cd661b..2e57f10 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -242,7 +242,10 @@ checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" dependencies = [ "android-tzdata", "iana-time-zone", + "js-sys", "num-traits", + "serde", + "wasm-bindgen", "windows-targets", ] @@ -504,6 +507,7 @@ version = "1.3.58" dependencies = [ "anyhow", "bcrypt", + "chrono", "futures-util", "poem", "poem-openapi", diff --git a/Cargo.toml b/Cargo.toml index 08c1dff..d268101 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,4 +15,5 @@ serde = "1.0.190" thiserror = "1.0.50" anyhow = "1.0.75" serde_json = "1.0.108" +chrono = { version = "0.4.31", features = ["serde"] } diff --git a/src/main.rs b/src/main.rs index f5f4af0..5e16830 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,4 @@ +use chrono::{offset::Utc, DateTime}; use futures_util::{SinkExt, StreamExt}; use poem::{ endpoint::StaticFilesEndpoint, @@ -129,6 +130,7 @@ impl Api { .send(ChatMsg { username: name.clone(), message: text, + timestamp: Utc::now(), }) .is_err() { @@ -255,6 +257,7 @@ impl Api { struct ChatMsg { username: String, message: String, + timestamp: DateTime, } struct Api {