feat: Add heros support for sliding sync room. (#1691)

This patch is only based on https://github.com/matrix-org/sliding-sync/
pull/304 since the specification wasn't updated. I'm basically guessing
what a request and a response _should_ look like:

* `RoomSubscription` gains a new field: `include_heros`,
* `SlidingSyncRoom` gains a new field: `heros`,
* `SlidingSyncRoomHero` is a new type.
This commit is contained in:
Ivan Enderlin 2024-05-22 10:14:11 +02:00 committed by GitHub
parent 1c4f26af74
commit 1c1cfe9a7e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -12,7 +12,7 @@ use ruma_common::{
api::{request, response, Metadata},
metadata,
serde::{deserialize_cow_str, duration::opt_ms, Raw},
DeviceKeyAlgorithm, MilliSecondsSinceUnixEpoch, OwnedMxcUri, OwnedRoomId, RoomId,
DeviceKeyAlgorithm, MilliSecondsSinceUnixEpoch, OwnedMxcUri, OwnedRoomId, OwnedUserId, RoomId,
};
use ruma_events::{
receipt::SyncReceiptEvent, typing::SyncTypingEvent, AnyGlobalAccountDataEvent,
@ -362,6 +362,10 @@ pub struct RoomSubscription {
/// The maximum number of timeline events to return per room. Sticky.
#[serde(skip_serializing_if = "Option::is_none")]
pub timeline_limit: Option<UInt>,
/// Include the room heroes. Sticky.
#[serde(skip_serializing_if = "Option::is_none")]
pub include_heroes: Option<bool>,
}
/// Operation applied to the specific SlidingSyncList
@ -479,6 +483,10 @@ pub struct SlidingSyncRoom {
/// relying on the latest event.
#[serde(skip_serializing_if = "Option::is_none")]
pub timestamp: Option<MilliSecondsSinceUnixEpoch>,
/// Heroes of the room, if requested by a room subscription.
#[serde(skip_serializing_if = "Option::is_none")]
pub heroes: Option<Vec<SlidingSyncRoomHero>>,
}
impl SlidingSyncRoom {
@ -488,6 +496,23 @@ impl SlidingSyncRoom {
}
}
/// A sliding sync room hero.
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct SlidingSyncRoomHero {
/// The user ID of the hero.
#[serde(skip_serializing_if = "Option::is_none")]
pub user_id: Option<OwnedUserId>,
/// The name of the hero.
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
/// The avatar of the hero.
#[serde(skip_serializing_if = "Option::is_none")]
pub avatar: Option<OwnedMxcUri>,
}
/// Sliding-Sync extension configuration.
#[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]