Added timestamp to msg object

This commit is contained in:
Lucas Schumacher 2023-11-07 16:19:48 -05:00
parent dfa0a6a7e8
commit e639604ef6
3 changed files with 8 additions and 0 deletions

4
Cargo.lock generated
View File

@ -242,7 +242,10 @@ checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38"
dependencies = [ dependencies = [
"android-tzdata", "android-tzdata",
"iana-time-zone", "iana-time-zone",
"js-sys",
"num-traits", "num-traits",
"serde",
"wasm-bindgen",
"windows-targets", "windows-targets",
] ]
@ -504,6 +507,7 @@ version = "1.3.58"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bcrypt", "bcrypt",
"chrono",
"futures-util", "futures-util",
"poem", "poem",
"poem-openapi", "poem-openapi",

View File

@ -15,4 +15,5 @@ serde = "1.0.190"
thiserror = "1.0.50" thiserror = "1.0.50"
anyhow = "1.0.75" anyhow = "1.0.75"
serde_json = "1.0.108" serde_json = "1.0.108"
chrono = { version = "0.4.31", features = ["serde"] }

View File

@ -1,3 +1,4 @@
use chrono::{offset::Utc, DateTime};
use futures_util::{SinkExt, StreamExt}; use futures_util::{SinkExt, StreamExt};
use poem::{ use poem::{
endpoint::StaticFilesEndpoint, endpoint::StaticFilesEndpoint,
@ -129,6 +130,7 @@ impl Api {
.send(ChatMsg { .send(ChatMsg {
username: name.clone(), username: name.clone(),
message: text, message: text,
timestamp: Utc::now(),
}) })
.is_err() .is_err()
{ {
@ -255,6 +257,7 @@ impl Api {
struct ChatMsg { struct ChatMsg {
username: String, username: String,
message: String, message: String,
timestamp: DateTime<Utc>,
} }
struct Api { struct Api {