mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-19 14:19:06 -04:00
fix(sdk): FrozenSlidingSyncRoom.timeline_queue must serialize to timeline
fix(sdk): `FrozenSlidingSyncRoom.timeline_queue` must serialize to `timeline`
This commit is contained in:
@@ -783,9 +783,47 @@ struct FrozenSlidingSyncRoom {
|
||||
room_id: OwnedRoomId,
|
||||
inner: v4::SlidingSyncRoom,
|
||||
prev_batch: Option<String>,
|
||||
#[serde(rename = "timeline")]
|
||||
timeline_queue: Vec<SyncTimelineEvent>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use matrix_sdk_base::deserialized_responses::TimelineEvent;
|
||||
use ruma::events::room::message::RoomMessageEventContent;
|
||||
use serde_json::json;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_frozen_sliding_sync_room_serialize() {
|
||||
let frozen_sliding_sync_room = FrozenSlidingSyncRoom {
|
||||
room_id: <&RoomId>::try_from("!29fhd83h92h0:example.com").unwrap().to_owned(),
|
||||
inner: v4::SlidingSyncRoom::default(),
|
||||
prev_batch: Some("let it go!".to_owned()),
|
||||
timeline_queue: vec![TimelineEvent {
|
||||
event: Raw::new(&json! ({
|
||||
"content": RoomMessageEventContent::text_plain("let it gooo!"),
|
||||
"type": "m.room.message",
|
||||
"event_id": "$xxxxx:example.org",
|
||||
"room_id": "!someroom:example.com",
|
||||
"origin_server_ts": 2189,
|
||||
"sender": "@bob:example.com",
|
||||
}))
|
||||
.unwrap()
|
||||
.cast(),
|
||||
encryption_info: None,
|
||||
}
|
||||
.into()],
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
serde_json::to_string(&frozen_sliding_sync_room).unwrap(),
|
||||
"{\"room_id\":\"!29fhd83h92h0:example.com\",\"inner\":{},\"prev_batch\":\"let it go!\",\"timeline\":[{\"event\":{\"content\":{\"body\":\"let it gooo!\",\"msgtype\":\"m.text\"},\"event_id\":\"$xxxxx:example.org\",\"origin_server_ts\":2189,\"room_id\":\"!someroom:example.com\",\"sender\":\"@bob:example.com\",\"type\":\"m.room.message\"},\"encryption_info\":null}]}",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&SlidingSyncRoom> for FrozenSlidingSyncRoom {
|
||||
fn from(value: &SlidingSyncRoom) -> Self {
|
||||
let locked_tl = value.timeline_queue.lock_ref();
|
||||
|
||||
Reference in New Issue
Block a user