Skip to content

Commit

Permalink
client-api: Add support for read receipts for threads
Browse files Browse the repository at this point in the history
According to MSC3771
  • Loading branch information
zecakeh committed Oct 2, 2022
1 parent 1eee497 commit 36611d6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions crates/ruma-client-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Improvements:
* The fields added to `RoomEventFilter` were removed by MSC3856
* Add support for the threads list API (MSC3856 / Matrix 1.4)
* Stabilize support for private read receipts
* Add support for read receipts for threads (MSC3771 / Matrix 1.4)

# 0.15.1

Expand Down
12 changes: 11 additions & 1 deletion crates/ruma-client-api/src/receipt/create_receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub mod v3 {

use ruma_common::{
api::ruma_api,
events::receipt::ReceiptThread,
serde::{OrdAsRefStr, PartialEqAsRefStr, PartialOrdAsRefStr, StringEnum},
EventId, RoomId,
};
Expand Down Expand Up @@ -37,6 +38,15 @@ pub mod v3 {
/// The event ID to acknowledge up to.
#[ruma_api(path)]
pub event_id: &'a EventId,

/// The thread this receipt applies to.
///
/// *Note* that this must be the default value if used with
/// [`ReceiptType::FullyRead`].
///
/// Defaults to [`ReceiptThread::Unthreaded`].
#[serde(rename = "thread_id", skip_serializing_if = "ruma_common::serde::is_default")]
pub thread: ReceiptThread,
}

#[derive(Default)]
Expand All @@ -48,7 +58,7 @@ pub mod v3 {
impl<'a> Request<'a> {
/// Creates a new `Request` with the given room ID, receipt type and event ID.
pub fn new(room_id: &'a RoomId, receipt_type: ReceiptType, event_id: &'a EventId) -> Self {
Self { room_id, receipt_type, event_id }
Self { room_id, receipt_type, event_id, thread: ReceiptThread::default() }
}
}

Expand Down

0 comments on commit 36611d6

Please sign in to comment.