Add room state accessor iterating state_keys joined by respective event_id.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2025-10-07 18:10:24 +00:00
parent 97e709492c
commit 5c61b4d4a3
2 changed files with 25 additions and 1 deletions

View File

@@ -1,4 +1,4 @@
#![type_length_limit = "163840"] //TODO: REDUCE ME
#![type_length_limit = "589824"] //TODO: REDUCE ME
#![allow(clippy::toplevel_ref_arg)]
pub mod client;

View File

@@ -99,6 +99,30 @@ where
.await
}
/// Iterates the state_keys for an event_type in the state joined by the
/// `event_id` from the current state.
#[implement(super::Service)]
#[tracing::instrument(skip(self), level = "debug")]
pub fn room_state_keys_with_ids<'a, Id>(
&'a self,
room_id: &'a RoomId,
event_type: &'a StateEventType,
) -> impl Stream<Item = Result<(StateKey, Id)>> + Send + 'a
where
Id: for<'de> Deserialize<'de> + Send + Sized + ToOwned + 'a,
<Id as ToOwned>::Owned: Borrow<EventId>,
{
self.services
.state
.get_room_shortstatehash(room_id)
.map_ok(|shortstatehash| {
self.state_keys_with_ids(shortstatehash, event_type)
.map(Ok)
})
.map_err(move |e| err!(Database("Missing state for {room_id:?}: {e:?}")))
.try_flatten_stream()
}
/// Iterates the state_keys for an event_type in the state
#[implement(super::Service)]
#[tracing::instrument(skip(self), level = "debug")]