simplify get_pdu() interface; eliminate unconditional Arc

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-11-29 08:26:27 +00:00
parent 58be22e695
commit 6175e72f1c
16 changed files with 51 additions and 52 deletions

View file

@ -17,7 +17,11 @@ use std::{
time::Instant,
};
use conduit::{utils::MutexMap, Err, PduEvent, Result, Server};
use conduit::{
utils::{MutexMap, TryFutureExtExt},
Err, PduEvent, Result, Server,
};
use futures::TryFutureExt;
use ruma::{
events::room::create::RoomCreateEventContent, state_res::RoomVersion, EventId, OwnedEventId, OwnedRoomId, RoomId,
RoomVersionId,
@ -94,7 +98,12 @@ impl Service {
async fn event_exists(&self, event_id: Arc<EventId>) -> bool { self.services.timeline.pdu_exists(&event_id).await }
async fn event_fetch(&self, event_id: Arc<EventId>) -> Option<Arc<PduEvent>> {
self.services.timeline.get_pdu(&event_id).await.ok()
self.services
.timeline
.get_pdu(&event_id)
.map_ok(Arc::new)
.ok()
.await
}
}