add get_pdu_owned sans Arc; improve client/room/event handler

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-11-06 06:20:39 +00:00
commit 7450c654ae
7 changed files with 50 additions and 38 deletions

View file

@ -123,15 +123,18 @@ impl Data {
///
/// Checks the `eventid_outlierpdu` Tree if not found in the timeline.
pub(super) async fn get_pdu(&self, event_id: &EventId) -> Result<Arc<PduEvent>> {
self.get_pdu_owned(event_id).await.map(Arc::new)
}
/// Returns the pdu.
///
/// Checks the `eventid_outlierpdu` Tree if not found in the timeline.
pub(super) async fn get_pdu_owned(&self, event_id: &EventId) -> Result<PduEvent> {
if let Ok(pdu) = self.get_non_outlier_pdu(event_id).await {
return Ok(Arc::new(pdu));
return Ok(pdu);
}
self.eventid_outlierpdu
.get(event_id)
.await
.deserialized()
.map(Arc::new)
self.eventid_outlierpdu.get(event_id).await.deserialized()
}
/// Like get_non_outlier_pdu(), but without the expense of fetching and