Turn messages into stub SubscribeMessage struct

This commit is contained in:
Lucien Greathouse
2019-09-23 10:53:11 -07:00
parent a46d467b75
commit bd33aebc3d
5 changed files with 28 additions and 12 deletions

View File

@@ -13,8 +13,8 @@ use crate::{
serve_session::ServeSession,
web::{
interface::{
ErrorResponse, Instance, ReadResponse, ServerInfoResponse, SubscribeResponse,
PROTOCOL_VERSION, SERVER_VERSION,
ErrorResponse, Instance, ReadResponse, ServerInfoResponse, SubscribeMessage,
SubscribeResponse, PROTOCOL_VERSION, SERVER_VERSION,
},
util::{json, json_ok},
},
@@ -90,11 +90,19 @@ impl<F: ImfsFetcher> ApiService<F> {
}
Box::new(receiver.then(move |result| match result {
Ok((message_cursor, messages)) => json_ok(SubscribeResponse {
session_id,
message_cursor,
messages,
}),
Ok((message_cursor, messages)) => {
// TODO: Transform applied patch sets into subscribe responses
let api_messages = messages
.into_iter()
.map(|_message| SubscribeMessage)
.collect();
json_ok(SubscribeResponse {
session_id,
message_cursor,
messages: api_messages,
})
}
Err(_) => json(
ErrorResponse::internal_error("Message queue disconnected sender"),
StatusCode::INTERNAL_SERVER_ERROR,