Private
Public Access
1
0

client: implements send_message

This commit is contained in:
2025-05-02 12:03:56 -07:00
parent 2106bce755
commit 07b55f8615
6 changed files with 133 additions and 9 deletions

View File

@@ -1,10 +1,13 @@
use async_trait::async_trait;
use std::collections::HashMap;
use time::OffsetDateTime;
use uuid::Uuid;
pub use crate::APIInterface;
use crate::{
api::http_client::Credentials,
model::{Conversation, ConversationID, JwtToken, Message, MessageID, UpdateItem, Event},
model::{Conversation, ConversationID, JwtToken, Message, MessageID, UpdateItem, Event, OutgoingMessage},
api::event_socket::EventSocket,
};
@@ -88,6 +91,20 @@ impl APIInterface for TestClient {
Err(TestError::ConversationNotFound)
}
async fn send_message(
&mut self,
outgoing_message: OutgoingMessage,
) -> Result<Message, Self::Error> {
let message = Message::builder()
.guid(Uuid::new_v4().to_string())
.text(outgoing_message.text)
.date(OffsetDateTime::now_utc())
.build();
self.messages.entry(outgoing_message.conversation_id).or_insert(vec![]).push(message.clone());
Ok(message)
}
async fn open_event_socket(&mut self) -> Result<impl EventSocket, Self::Error> {
Ok(TestEventSocket::new())
}