use of Option in StoreWakuMessageResponse for responses with or withoug msgs

This commit is contained in:
Ivan Folgueira Bande 2025-01-09 22:31:20 +01:00
parent bbcf401699
commit f1e4e024d5
No known key found for this signature in database
GPG Key ID: 3C117481F89E24A7
2 changed files with 11 additions and 8 deletions

View File

@ -152,13 +152,16 @@ impl App<Running> {
Some(time_start), Some(time_start),
None, None,
None).await.unwrap(); None).await.unwrap();
let messages:Vec<_> = messages
.iter() let messages: Vec<_> = messages
.map(|store_resp_msg| { .into_iter()
<Chat2Message as Message>::decode(store_resp_msg.message.payload()) // we expect messages because the query was passed with include_data == true
.expect("Toy chat messages should be decodeable") .filter(|item| item.message.is_some())
}) .map(|store_resp_msg| {
.collect(); <Chat2Message as Message>::decode(store_resp_msg.message.unwrap().payload())
.expect("Toy chat messages should be decodeable")
})
.collect();
if !messages.is_empty() { if !messages.is_empty() {
*self.messages.write().unwrap() = messages; *self.messages.write().unwrap() = messages;

View File

@ -109,7 +109,7 @@ impl StoreQueryRequest {
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct StoreWakuMessageResponse { pub struct StoreWakuMessageResponse {
pub message_hash: MessageHash, pub message_hash: MessageHash,
pub message: WakuStoreRespMessage, pub message: Option<WakuStoreRespMessage>, // None if include_data == false
pub pubsub_topic: String, pub pubsub_topic: String,
} }