From 3dfb500bbab42957eae7001b649a0e4adc064679 Mon Sep 17 00:00:00 2001 From: poljar Date: Fri, 3 Apr 2020 14:01:12 +0200 Subject: [PATCH] sync_events: Fix RoomSummary serde attributes * Create an empty heroes vector if the response doesn't contain it. The heroes map is strictly optional and as is deserialization might fail for the whole response unless we allow it to be optional. * Rename the room summary fields during (de)serialization. --- src/r0/sync/sync_events.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/r0/sync/sync_events.rs b/src/r0/sync/sync_events.rs index 9c5a8f38..cd5740ff 100644 --- a/src/r0/sync/sync_events.rs +++ b/src/r0/sync/sync_events.rs @@ -260,15 +260,17 @@ pub struct Ephemeral { pub struct RoomSummary { /// Users which can be used to generate a room name if the room does not have /// one. Required if room name or canonical aliases are not set or empty. - #[serde(skip_serializing_if = "Vec::is_empty")] + #[serde(rename = "m.heroes", default, skip_serializing_if = "Vec::is_empty")] pub heroes: Vec, /// Number of users whose membership status is `join`. /// Required if field has changed since last sync; otherwise, it may be /// omitted. + #[serde(rename = "m.joined_member_count")] pub joined_member_count: Option, /// Number of users whose membership status is `invite`. /// Required if field has changed since last sync; otherwise, it may be /// omitted. + #[serde(rename = "m.invited_member_count")] pub invited_member_count: Option, }