client-api: Use JsOption for avatar field in sliding sync response

The `avatar` field has different semantics whether it's `undefined` (hasn't
changed since previous time) vs `null` (it's now unset). Let's reflect
this in the API of the `SlidingSyncRoom` response. While a public breaking API
change, sliding sync is still considered experimental, so we're not bumping
the main version here.
This commit is contained in:
Benjamin Bouvier 2023-11-20 22:47:45 +01:00 committed by GitHub
parent 5446ea979b
commit 9728f97505
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,7 @@
use std::{collections::BTreeMap, time::Duration};
use js_int::UInt;
use js_option::JsOption;
use ruma_common::{
api::{request, response, Metadata},
metadata,
@ -421,8 +422,8 @@ pub struct SlidingSyncRoom {
pub name: Option<String>,
/// The avatar of the room.
#[serde(skip_serializing_if = "Option::is_none")]
pub avatar: Option<OwnedMxcUri>,
#[serde(default, skip_serializing_if = "JsOption::is_undefined")]
pub avatar: JsOption<OwnedMxcUri>,
/// Was this an initial response.
#[serde(skip_serializing_if = "Option::is_none")]