Fixed challenge 03

Signed-off-by: TuDatTr <tuan-dat.tran@tudattr.dev>
main
TuDatTr 2024-02-02 03:53:18 +01:00
parent 4c1aff8142
commit f31fb3bcdc
4 changed files with 5 additions and 5 deletions

View File

@ -11,7 +11,7 @@ type AppState = Arc<Mutex<State>>;
#[derive(Default)] #[derive(Default)]
pub struct State { pub struct State {
uid: IdCounter, uid: IdCounter,
message: String, message: Vec<String>,
} }
#[derive(Debug, Default)] #[derive(Debug, Default)]

View File

@ -42,7 +42,7 @@ pub enum MessageBody {
ReadOk { ReadOk {
msg_id: u64, msg_id: u64,
in_reply_to: u64, in_reply_to: u64,
message: String, message: Vec<String>,
}, },
Default, Default,
} }

View File

@ -1,5 +1,5 @@
use axum::{extract::State, http::StatusCode, Json}; use axum::{extract::State, http::StatusCode, Json};
use tracing::{info}; use tracing::info;
use crate::{ use crate::{
messages::{Message, MessageBody}, messages::{Message, MessageBody},
@ -51,7 +51,7 @@ pub async fn challenge(
let in_reply_to = msg_id; let in_reply_to = msg_id;
{ {
let mut local_state = state.lock().unwrap(); let mut local_state = state.lock().unwrap();
local_state.message = message; local_state.message.push(message);
} }
MessageBody::BroadcastOk { MessageBody::BroadcastOk {
msg_id, msg_id,

View File

@ -85,7 +85,7 @@ async fn test_rw() {
"type": "read_ok", "type": "read_ok",
"msg_id": 2, "msg_id": 2,
"in_reply_to": 2, "in_reply_to": 2,
"message": message "message": vec![message]
} }
} }
); );