mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-12 19:56:48 +00:00
fix(client): Allow setting read receipts on backfilled events
This commit is contained in:
2 files changed
+5
-14
No files matched your search
@@ -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
|
||||
|
||||
@@ -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<OwnedEventId, Receipts> = BTreeMap::from_iter([(
|
||||
|
||||
Reference in new issue
Block a user