Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions bindings/matrix-sdk-ffi/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

use anyhow::{bail, Context};
use matrix_sdk::IdParseError;
use matrix_sdk_base::deserialized_responses::RawAnySyncOrStrippedState;
use matrix_sdk_ui::timeline::TimelineEventItemId;
use ruma::{
events::{
Expand Down Expand Up @@ -747,3 +748,33 @@ impl TryFrom<EventOrTransactionId> for TimelineEventItemId {
}
}
}

/// A raw state event, either synced or stripped (for invited rooms).
///
/// The event content is provided as a JSON string.
#[derive(Clone, uniffi::Enum)]
pub enum RawSyncOrStrippedStateEvent {
/// A state event from a room in joined or left state.
Sync {
/// The raw JSON content of the event.
json: String,
},
/// A stripped state event from a room in invited state.
Stripped {
/// The raw JSON content of the event.
json: String,
},
}

impl From<RawAnySyncOrStrippedState> for RawSyncOrStrippedStateEvent {
fn from(value: RawAnySyncOrStrippedState) -> Self {
match value {
RawAnySyncOrStrippedState::Sync(raw) => {
RawSyncOrStrippedStateEvent::Sync { json: raw.json().to_string() }
}
RawAnySyncOrStrippedState::Stripped(raw) => {
RawSyncOrStrippedStateEvent::Stripped { json: raw.json().to_string() }
}
}
}
}
20 changes: 19 additions & 1 deletion bindings/matrix-sdk-ffi/src/room/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ use crate::{
chunk_iterator::ChunkIterator,
client::{JoinRule, RoomVisibility},
error::{ClientError, MediaInfoError, NotYetImplemented, QueueWedgeError, RoomError},
event::TimelineEvent,
event::{RawSyncOrStrippedStateEvent, StateEventType, TimelineEvent},
identity_status_change::IdentityStatusChange,
live_location_share::{LastLocation, LiveLocationShare},
room_member::{RoomMember, RoomMemberWithSenderInfo},
Expand Down Expand Up @@ -365,6 +365,24 @@ impl Room {
Ok(())
}

/// Get all state events of a given type in this room.
///
/// # Arguments
///
/// * `event_type` - The type of the state event to retrieve.
///
/// # Returns
///
/// A list of raw state events, either synced or stripped (for invited
/// rooms). Each event contains its raw JSON representation.
pub async fn get_state_events(
&self,
event_type: StateEventType,
) -> Result<Vec<RawSyncOrStrippedStateEvent>, ClientError> {
let events = self.inner.get_state_events(event_type.into()).await?;
Ok(events.into_iter().map(Into::into).collect())
}

/// Get the membership details for the current user.
///
/// Returns:
Expand Down
7 changes: 5 additions & 2 deletions crates/matrix-sdk-ui/src/room_list_service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,11 @@ const DEFAULT_REQUIRED_STATE: &[(StateEventType, &str)] = &[

/// The default `required_state` constant value for sliding sync room
/// subscriptions that must be added to `DEFAULT_REQUIRED_STATE`.
const DEFAULT_ROOM_SUBSCRIPTION_EXTRA_REQUIRED_STATE: &[(StateEventType, &str)] =
&[(StateEventType::RoomPinnedEvents, "")];
const DEFAULT_ROOM_SUBSCRIPTION_EXTRA_REQUIRED_STATE: &[(StateEventType, &str)] = &[
(StateEventType::RoomPinnedEvents, ""),
// TODO add this to ruma properly
(StateEventType::Custom { value: "im.vector.modular.widgets" }, "*"),
];

/// The default `timeline_limit` value when used with room subscriptions.
const DEFAULT_ROOM_SUBSCRIPTION_TIMELINE_LIMIT: u32 = 20;
Expand Down
Loading