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.
This commit is contained in:
poljar 2020-04-03 14:01:12 +02:00 committed by GitHub
parent 09ac2404de
commit 3dfb500bba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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<String>,
/// 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<UInt>,
/// 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<UInt>,
}