From ffdf47d1ea34a571431b85baa00f5f77a1c5e73c Mon Sep 17 00:00:00 2001 From: strawberry Date: Thu, 30 May 2024 23:36:48 -0400 Subject: [PATCH] add `latest_pdu_in_room` timeline function Signed-off-by: strawberry --- src/service/rooms/timeline/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/service/rooms/timeline/mod.rs b/src/service/rooms/timeline/mod.rs index 04f03242..6c534b4b 100644 --- a/src/service/rooms/timeline/mod.rs +++ b/src/service/rooms/timeline/mod.rs @@ -82,6 +82,14 @@ impl Service { .transpose() } + #[tracing::instrument(skip(self))] + pub fn latest_pdu_in_room(&self, room_id: &RoomId) -> Result>> { + self.all_pdus(user_id!("@placeholder:conduwuit.placeholder"), room_id)? + .last() + .map(|o| o.map(|(_, p)| Arc::new(p))) + .transpose() + } + #[tracing::instrument(skip(self))] pub fn last_timeline_count(&self, sender_user: &UserId, room_id: &RoomId) -> Result { self.db.last_timeline_count(sender_user, room_id)