mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-18 13:40:55 -04:00
room list service: always include the m.room.create state event in a room subscription
This commit is contained in:
@@ -18,7 +18,7 @@ use std::{ops::Deref, sync::Arc};
|
||||
|
||||
use async_once_cell::OnceCell as AsyncOnceCell;
|
||||
use matrix_sdk::{event_cache, SlidingSync, SlidingSyncRoom};
|
||||
use ruma::{api::client::sync::sync_events::v4::RoomSubscription, RoomId};
|
||||
use ruma::{api::client::sync::sync_events::v4::RoomSubscription, events::StateEventType, RoomId};
|
||||
|
||||
use super::Error;
|
||||
use crate::{
|
||||
@@ -98,7 +98,21 @@ impl Room {
|
||||
/// It means that all events from this room will be received every time, no
|
||||
/// matter how the `RoomList` is configured.
|
||||
pub fn subscribe(&self, settings: Option<RoomSubscription>) {
|
||||
self.inner.sliding_sync.subscribe_to_room(self.inner.room.room_id().to_owned(), settings)
|
||||
let mut settings = settings.unwrap_or_default();
|
||||
|
||||
// Make sure to always include the room creation event in the required state
|
||||
// events, to know what the room version is.
|
||||
if !settings
|
||||
.required_state
|
||||
.iter()
|
||||
.any(|(event_type, _state_key)| *event_type == StateEventType::RoomCreate)
|
||||
{
|
||||
settings.required_state.push((StateEventType::RoomCreate, "".to_owned()));
|
||||
}
|
||||
|
||||
self.inner
|
||||
.sliding_sync
|
||||
.subscribe_to_room(self.inner.room.room_id().to_owned(), Some(settings))
|
||||
}
|
||||
|
||||
/// Unsubscribe to this room.
|
||||
|
||||
@@ -2411,6 +2411,7 @@ async fn test_room_subscription() -> Result<(), Error> {
|
||||
["m.room.topic", ""],
|
||||
["m.room.avatar", ""],
|
||||
["m.room.canonical_alias", ""],
|
||||
["m.room.create", ""], // Added even when it's not specified
|
||||
],
|
||||
"timeline_limit": 30,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user