Fix event subscription envelopes

This commit is contained in:
2022-08-27 03:00:22 +02:00
parent f2cdbe0638
commit f3c940a96c

View File

@ -10,7 +10,7 @@ struct Input {}
#[derive(Serialize, Deserialize, Clone)]
struct Output {
event: Option<Event>,
events: Vec<Event>,
}
pub async fn handle(
@ -45,16 +45,16 @@ async fn subscribe(
.send(OutputEnvelope {
error: None,
request_nr: req_nr,
data: to_value(event).unwrap(),
data: serde_json::json![{"events": [event]}],
})
.await;
}
});
Ok(Output { event: None })
Ok(Output { events: vec![] })
}
None => {
if let Some(event) = rx.recv().await {
Ok(Output { event: Some(event) })
Ok(Output { events: vec![event] })
} else {
Err(Error::new(
ErrorKind::SubscriptionError,