Started working on attachment store
This commit is contained in:
@@ -6,13 +6,16 @@ use uuid::Uuid;
|
||||
|
||||
pub use crate::APIInterface;
|
||||
use crate::{
|
||||
api::http_client::Credentials,
|
||||
model::{Conversation, ConversationID, JwtToken, Message, MessageID, UpdateItem, Event, OutgoingMessage},
|
||||
api::event_socket::EventSocket,
|
||||
};
|
||||
api::http_client::Credentials,
|
||||
model::{
|
||||
Conversation, ConversationID, Event, JwtToken, Message, MessageID, OutgoingMessage,
|
||||
UpdateItem,
|
||||
},
|
||||
};
|
||||
|
||||
use futures_util::StreamExt;
|
||||
use futures_util::stream::BoxStream;
|
||||
use futures_util::StreamExt;
|
||||
|
||||
pub struct TestClient {
|
||||
pub version: &'static str,
|
||||
@@ -59,7 +62,7 @@ impl EventSocket for TestEventSocket {
|
||||
let results: Vec<Result<Vec<UpdateItem>, TestError>> = vec![];
|
||||
futures_util::stream::iter(results.into_iter()).boxed()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl APIInterface for TestClient {
|
||||
@@ -78,21 +81,21 @@ impl APIInterface for TestClient {
|
||||
}
|
||||
|
||||
async fn get_messages(
|
||||
&mut self,
|
||||
conversation_id: &ConversationID,
|
||||
limit: Option<u32>,
|
||||
before: Option<MessageID>,
|
||||
after: Option<MessageID>
|
||||
&mut self,
|
||||
conversation_id: &ConversationID,
|
||||
limit: Option<u32>,
|
||||
before: Option<MessageID>,
|
||||
after: Option<MessageID>,
|
||||
) -> Result<Vec<Message>, Self::Error> {
|
||||
if let Some(messages) = self.messages.get(conversation_id) {
|
||||
return Ok(messages.clone())
|
||||
return Ok(messages.clone());
|
||||
}
|
||||
|
||||
Err(TestError::ConversationNotFound)
|
||||
}
|
||||
|
||||
async fn send_message(
|
||||
&mut self,
|
||||
&mut self,
|
||||
outgoing_message: &OutgoingMessage,
|
||||
) -> Result<Message, Self::Error> {
|
||||
let message = Message::builder()
|
||||
@@ -101,13 +104,21 @@ impl APIInterface for TestClient {
|
||||
.date(OffsetDateTime::now_utc())
|
||||
.build();
|
||||
|
||||
self.messages.entry(outgoing_message.conversation_id.clone()).or_insert(vec![]).push(message.clone());
|
||||
self.messages
|
||||
.entry(outgoing_message.conversation_id.clone())
|
||||
.or_insert(vec![])
|
||||
.push(message.clone());
|
||||
Ok(message)
|
||||
}
|
||||
|
||||
async fn open_event_socket(&mut self, _update_seq: Option<u64>) -> Result<impl EventSocket, Self::Error> {
|
||||
async fn open_event_socket(
|
||||
&mut self,
|
||||
_update_seq: Option<u64>,
|
||||
) -> Result<impl EventSocket, Self::Error> {
|
||||
Ok(TestEventSocket::new())
|
||||
}
|
||||
|
||||
async fn fetch_attachment_data(&mut self, guid: &String) -> Result<Vec<u8>, Self::Error> {
|
||||
Ok(vec![])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user