mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-08 07:56:55 -04:00
feat(ffi): Add Room::load_or_fetch_event to the FFI layer
This way we can retrieve random events in a room and check their properties - this is needed to decide whether a permalink for an event should open in a thread or not
This commit is contained in:
committed by
Jorge Martin Espinosa
parent
2166de7b0d
commit
14ca34b09b
@@ -27,7 +27,7 @@ use ruma::{
|
||||
join_rules::JoinRule as RumaJoinRule, message::RoomMessageEventContentWithoutRelation,
|
||||
MediaSource,
|
||||
},
|
||||
AnyMessageLikeEventContent, AnySyncTimelineEvent,
|
||||
AnyMessageLikeEventContent, AnySyncTimelineEvent, AnyTimelineEvent,
|
||||
},
|
||||
EventId, Int, OwnedDeviceId, OwnedRoomOrAliasId, OwnedServerName, OwnedUserId, RoomAliasId,
|
||||
ServerName, UserId,
|
||||
@@ -39,6 +39,7 @@ use crate::{
|
||||
chunk_iterator::ChunkIterator,
|
||||
client::{JoinRule, RoomVisibility},
|
||||
error::{ClientError, MediaInfoError, NotYetImplemented, RoomError},
|
||||
event::TimelineEvent,
|
||||
identity_status_change::IdentityStatusChange,
|
||||
live_location_share::{LastLocation, LiveLocationShare},
|
||||
room_member::{RoomMember, RoomMemberWithSenderInfo},
|
||||
@@ -1178,6 +1179,17 @@ impl Room {
|
||||
.await?
|
||||
.map(|sub| ThreadSubscription { automatic: sub.automatic }))
|
||||
}
|
||||
|
||||
/// Either loads the event associated with the `event_id` from the event
|
||||
/// cache or fetches it from the homeserver.
|
||||
pub async fn load_or_fetch_event(
|
||||
&self,
|
||||
event_id: String,
|
||||
) -> Result<TimelineEvent, ClientError> {
|
||||
let event_id = EventId::parse(event_id)?;
|
||||
let timeline_event = self.inner.load_or_fetch_event(&event_id, None).await?;
|
||||
Ok(timeline_event.kind.into_raw().deserialize_as_unchecked::<AnyTimelineEvent>()?.into())
|
||||
}
|
||||
}
|
||||
|
||||
/// A thread subscription (MSC4306).
|
||||
|
||||
Reference in New Issue
Block a user