From 76ace2bc09783294596a70e862b9a0b8b2a3ee15 Mon Sep 17 00:00:00 2001 From: Jade Ellis Date: Sun, 8 Nov 2026 20:19:56 +0000 Subject: [PATCH] fix(client): Allow setting read receipts on backfilled events --- src/api/client/read_marker.rs | 14 +++----------- src/service/rooms/read_receipt/mod.rs | 5 ++--- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/api/client/read_marker.rs b/src/api/client/read_marker.rs index 2f8b21a39..1d96f05d2 100644 --- a/src/api/client/read_marker.rs +++ b/src/api/client/read_marker.rs @@ -1,7 +1,7 @@ use std::collections::BTreeMap; use axum::extract::State; -use conduwuit::{Err, PduCount, Result, err}; +use conduwuit::{Err, Result, err}; use ruma::{ MilliSecondsSinceUnixEpoch, api::client::{read_marker::set_read_marker, receipt::create_receipt}, @@ -94,11 +94,7 @@ pub(crate) async fn set_read_marker_route( .await .map_err(|_| err!(Request(NotFound("Event not found."))))?; - let PduCount::Normal(count) = count else { - return Err!(Request(InvalidParam( - "Event is a backfilled PDU and cannot be marked as read." - ))); - }; + let count = count.into_unsigned(); services .rooms @@ -192,11 +188,7 @@ pub(crate) async fn create_receipt_route( .await .map_err(|_| err!(Request(NotFound("Event not found."))))?; - let PduCount::Normal(count) = count else { - return Err!(Request(InvalidParam( - "Event is a backfilled PDU and cannot be marked as read." - ))); - }; + let count = count.into_unsigned(); services .rooms diff --git a/src/service/rooms/read_receipt/mod.rs b/src/service/rooms/read_receipt/mod.rs index 2815828fd..097c22b22 100644 --- a/src/service/rooms/read_receipt/mod.rs +++ b/src/service/rooms/read_receipt/mod.rs @@ -93,7 +93,7 @@ impl Service { }); let (pdu_count, shortroomid) = try_join!(pdu_count, shortroomid)?; - let shorteventid = PduCount::Normal(pdu_count); + let shorteventid = PduCount::from_unsigned(pdu_count); let pdu_id: RawPduId = PduId { shortroomid, shorteventid }.into(); let pdu = self.services.timeline.get_pdu_from_id(&pdu_id).await?; @@ -101,8 +101,7 @@ impl Service { let user_id: OwnedUserId = user_id.to_owned(); let mut receipt = ruma::events::receipt::Receipt::default(); - // TODO: start storing the timestamp so we can return one - receipt.ts = None; + receipt.ts = Some(pdu.origin_server_ts()); receipt.thread = ruma::events::receipt::ReceiptThread::Unthreaded; let content: BTreeMap = BTreeMap::from_iter([(