add latest_pdu_in_room timeline function

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-05-30 23:36:48 -04:00
parent 1af65e695d
commit ffdf47d1ea

View file

@ -82,6 +82,14 @@ impl Service {
.transpose() .transpose()
} }
#[tracing::instrument(skip(self))]
pub fn latest_pdu_in_room(&self, room_id: &RoomId) -> Result<Option<Arc<PduEvent>>> {
self.all_pdus(user_id!("@placeholder:conduwuit.placeholder"), room_id)?
.last()
.map(|o| o.map(|(_, p)| Arc::new(p)))
.transpose()
}
#[tracing::instrument(skip(self))] #[tracing::instrument(skip(self))]
pub fn last_timeline_count(&self, sender_user: &UserId, room_id: &RoomId) -> Result<PduCount> { pub fn last_timeline_count(&self, sender_user: &UserId, room_id: &RoomId) -> Result<PduCount> {
self.db.last_timeline_count(sender_user, room_id) self.db.last_timeline_count(sender_user, room_id)