diff --git a/chat/src/routes/Chat.tsx b/chat/src/routes/Chat.tsx index 9de09a7..a71e666 100644 --- a/chat/src/routes/Chat.tsx +++ b/chat/src/routes/Chat.tsx @@ -6,13 +6,13 @@ import { createEffect } from "solid-js"; * This type has to be kept in sync with the server-side types */ export type Message = { - to: string; - from: string; + recipient: string; + sender: string; text: string; /** * UTC unix timestamp in seconds */ - time: number; + time_utc: number; }; export default function Chat() { @@ -48,10 +48,10 @@ export default function Chat() { if (from === null || to === null) return; const message = { - to, - from, + recipient: to, + sender: from, text: messageText, - time: Date.now(), + time_utc: Date.now(), } satisfies Message; socket()?.send(JSON.stringify(message)); diff --git a/server/src/actor/delivery_service.rs b/server/src/actor/delivery_service.rs index 2acbe93..f711d89 100644 --- a/server/src/actor/delivery_service.rs +++ b/server/src/actor/delivery_service.rs @@ -36,7 +36,7 @@ async fn run_actor(mut actor: DeliveryService) { tracing::debug!("Processing message"); match message { Message::SendMessage(message) => { - let receiver = actor.users_by_name.get(&message.to); + let receiver = actor.users_by_name.get(&message.recipient); let Some(receiver) = receiver else { //TODO send error to user if receiver is not found tracing::error!("User not found"); diff --git a/server/src/actor/mod.rs b/server/src/actor/mod.rs index 20105b5..98c18f5 100644 --- a/server/src/actor/mod.rs +++ b/server/src/actor/mod.rs @@ -8,12 +8,11 @@ pub(super) mod websocket; #[derive(Serialize, Deserialize, Debug)] pub(in crate::actor) struct ChatMessage { - pub(super) to: Arc, - from: String, + pub(super) recipient: Arc, + sender: String, text: String, #[serde( with = "time::serde::timestamp::milliseconds", - rename = "time" )] time_utc: OffsetDateTime, }