message: resolve reviews, deserialization can fail, update for ruma removed PartialEq
parent
f13189d154
commit
c90eb6a938
|
@ -27,9 +27,6 @@ impl Deref for MessageWrapper {
|
||||||
impl PartialEq for MessageWrapper {
|
impl PartialEq for MessageWrapper {
|
||||||
fn eq(&self, other: &MessageWrapper) -> bool {
|
fn eq(&self, other: &MessageWrapper) -> bool {
|
||||||
self.0.event_id == other.0.event_id
|
self.0.event_id == other.0.event_id
|
||||||
&& self.0.room_id == other.0.room_id
|
|
||||||
&& self.0.origin_server_ts == other.0.origin_server_ts
|
|
||||||
&& self.0.sender == other.0.sender
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,14 +110,15 @@ pub(crate) mod ser_deser {
|
||||||
where
|
where
|
||||||
D: de::Deserializer<'de>,
|
D: de::Deserializer<'de>,
|
||||||
{
|
{
|
||||||
|
use serde::de::Error;
|
||||||
|
|
||||||
let messages: Vec<EventJson<MessageEvent>> = de::Deserialize::deserialize(deserializer)?;
|
let messages: Vec<EventJson<MessageEvent>> = de::Deserialize::deserialize(deserializer)?;
|
||||||
|
|
||||||
// TODO this should probably bail out if deserialization fails not skip the message
|
let mut msgs = vec![];
|
||||||
let msgs: Vec<MessageWrapper> = messages
|
for json in messages {
|
||||||
.into_iter()
|
let msg = json.deserialize().map_err(D::Error::custom)?;
|
||||||
.flat_map(|json| json.deserialize())
|
msgs.push(MessageWrapper(msg));
|
||||||
.map(MessageWrapper)
|
}
|
||||||
.collect();
|
|
||||||
|
|
||||||
Ok(MessageQueue { msgs })
|
Ok(MessageQueue { msgs })
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue