client-api: make user_id of SlidingSyncRoomHero mandatory (#1832)

This commit is contained in:
Matthias Ahouansou 2024-06-05 11:22:08 +00:00 committed by GitHub
parent 73535a7dd3
commit ef40b184b7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 3 deletions

View File

@ -19,6 +19,10 @@ Bug fixes:
- Rename `avatar` to `avatar_url` when (De)serializing - Rename `avatar` to `avatar_url` when (De)serializing
Bug fixes:
- `user_id` of `SlidingSyncRoomHero` is now mandatory
# 0.18.0 # 0.18.0
Bug fixes: Bug fixes:

View File

@ -504,12 +504,11 @@ impl SlidingSyncRoom {
} }
/// A sliding sync room hero. /// A sliding sync room hero.
#[derive(Clone, Debug, Default, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct SlidingSyncRoomHero { pub struct SlidingSyncRoomHero {
/// The user ID of the hero. /// The user ID of the hero.
#[serde(skip_serializing_if = "Option::is_none")] pub user_id: OwnedUserId,
pub user_id: Option<OwnedUserId>,
/// The name of the hero. /// The name of the hero.
#[serde(rename = "displayname", skip_serializing_if = "Option::is_none")] #[serde(rename = "displayname", skip_serializing_if = "Option::is_none")]
@ -520,6 +519,13 @@ pub struct SlidingSyncRoomHero {
pub avatar: Option<OwnedMxcUri>, pub avatar: Option<OwnedMxcUri>,
} }
impl SlidingSyncRoomHero {
/// Creates a new `SlidingSyncRoomHero` with the given user id.
pub fn new(user_id: OwnedUserId) -> Self {
Self { user_id, name: None, avatar: None }
}
}
/// Sliding-Sync extension configuration. /// Sliding-Sync extension configuration.
#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq)] #[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)] #[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]