diff --git a/bindings/matrix-sdk-ffi/src/room_info.rs b/bindings/matrix-sdk-ffi/src/room_info.rs index 8e89584a001..1dad22af707 100644 --- a/bindings/matrix-sdk-ffi/src/room_info.rs +++ b/bindings/matrix-sdk-ffi/src/room_info.rs @@ -53,6 +53,8 @@ pub struct RoomInfo { /// Events causing mentions/highlights for the user, according to their /// notification settings. num_unread_mentions: u64, + /// The currently pinned event ids + pinned_event_ids: Vec, } impl RoomInfo { @@ -64,6 +66,7 @@ impl RoomInfo { for (id, level) in power_levels_map.iter() { user_power_levels.insert(id.to_string(), *level); } + let pinned_event_ids = room.pinned_events().iter().map(|id| id.to_string()).collect(); Ok(Self { id: room.room_id().to_string(), @@ -109,6 +112,7 @@ impl RoomInfo { num_unread_messages: room.num_unread_messages(), num_unread_notifications: room.num_unread_notifications(), num_unread_mentions: room.num_unread_mentions(), + pinned_event_ids, }) } } diff --git a/bindings/matrix-sdk-ffi/src/timeline/mod.rs b/bindings/matrix-sdk-ffi/src/timeline/mod.rs index b67ec1e21c5..92eb1b62521 100644 --- a/bindings/matrix-sdk-ffi/src/timeline/mod.rs +++ b/bindings/matrix-sdk-ffi/src/timeline/mod.rs @@ -651,6 +651,26 @@ impl Timeline { )), } } + + /// Adds a new pinned event by sending an updated `m.room.pinned_events` + /// event containing the new event id. + /// + /// Returns `true` if we sent the request, `false` if the event was already + /// pinned. + async fn pin_event(&self, event_id: String) -> Result { + let event_id = EventId::parse(event_id).map_err(ClientError::from)?; + self.inner.pin_event(&event_id).await.map_err(ClientError::from) + } + + /// Adds a new pinned event by sending an updated `m.room.pinned_events` + /// event without the event id we want to remove. + /// + /// Returns `true` if we sent the request, `false` if the event wasn't + /// pinned + async fn unpin_event(&self, event_id: String) -> Result { + let event_id = EventId::parse(event_id).map_err(ClientError::from)?; + self.inner.unpin_event(&event_id).await.map_err(ClientError::from) + } } #[derive(uniffi::Object)]