Skip to content

Commit

Permalink
client-api: Stabilize support for private read receipts
Browse files Browse the repository at this point in the history
  • Loading branch information
zecakeh committed Oct 1, 2022
1 parent f068c3f commit 4898203
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 38 deletions.
3 changes: 3 additions & 0 deletions crates/ruma-client-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ Breaking changes:

* Remove `sync::sync_events::v3::DeviceLists` re-export
* Use `sync::sync_events::DeviceLists` instead
* `fully_read` field in `read_marker::set_read_marker` is no longer required
* Remove the `fully_read` argument from `read_marker::set_read_marker::Request::new`

Improvements:

* Add `M_BAD_ALIAS` to `error::ErrorKind`
* Remove the `unstable-msc3440` feature
* 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

# 0.15.1

Expand Down
1 change: 0 additions & 1 deletion crates/ruma-client-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ rustdoc-args = ["--cfg", "docsrs"]
compat = []
unstable-exhaustive-types = []
unstable-msc2246 = []
unstable-msc2285 = []
unstable-msc2666 = []
unstable-msc2448 = []
unstable-msc2654 = []
Expand Down
29 changes: 2 additions & 27 deletions crates/ruma-client-api/src/read_marker/set_read_marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,16 @@ pub mod v3 {
#[ruma_api(path)]
pub room_id: &'a RoomId,

/// The event ID the fully-read marker should be located at.
///
/// The event MUST belong to the room.
///
/// With the `unstable-msc2285` feature, this field is optional.
#[cfg(not(feature = "unstable-msc2285"))]
#[serde(rename = "m.fully_read")]
pub fully_read: &'a EventId,

/// The event ID the fully-read marker should be located at.
///
/// The event MUST belong to the room.
///
/// This is equivalent to calling the [`create_receipt`] endpoint with a
/// [`ReceiptType::FullyRead`].
///
/// Without the `unstable-msc2285` feature, this field is required.
///
/// [`create_receipt`]: crate::receipt::create_receipt
/// [`ReceiptType::FullyRead`]: crate::receipt::create_receipt::v3::ReceiptType::FullyRead
#[cfg(feature = "unstable-msc2285")]
#[serde(rename = "m.fully_read")]
#[serde(rename = "m.fully_read", skip_serializing_if = "Option::is_none")]
pub fully_read: Option<&'a EventId>,

/// The event ID to set the public read receipt location at.
Expand All @@ -69,8 +57,7 @@ pub mod v3 {
///
/// [`create_receipt`]: crate::receipt::create_receipt
/// [`ReceiptType::ReadPrivate`]: crate::receipt::create_receipt::v3::ReceiptType::ReadPrivate
#[cfg(feature = "unstable-msc2285")]
#[serde(rename = "org.matrix.msc2285.read.private", alias = "m.read.private", skip_serializing_if = "Option::is_none")]
#[serde(rename = "m.read.private", skip_serializing_if = "Option::is_none")]
pub private_read_receipt: Option<&'a EventId>,
}

Expand All @@ -81,19 +68,7 @@ pub mod v3 {
}

impl<'a> Request<'a> {
/// Creates a new `Request` with the given room ID and fully read event ID.
///
/// With the `unstable-msc2285` feature, this method doesn't have the `fully_read`
/// parameter.
#[cfg(not(feature = "unstable-msc2285"))]
pub fn new(room_id: &'a RoomId, fully_read: &'a EventId) -> Self {
Self { room_id, fully_read, read_receipt: None }
}

/// Creates a new `Request` with the given room ID.
///
/// Without the `unstable-msc2285` feature, this method takes a `fully_read` parameter.
#[cfg(feature = "unstable-msc2285")]
pub fn new(room_id: &'a RoomId) -> Self {
Self { room_id, fully_read: None, read_receipt: None, private_read_receipt: None }
}
Expand Down
10 changes: 4 additions & 6 deletions crates/ruma-client-api/src/receipt/create_receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub mod v3 {
///
/// This receipt is federated to other users.
///
/// [public read receipt]: https://spec.matrix.org/v1.3/client-server-api/#receipts
/// [public read receipt]: https://spec.matrix.org/v1.4/client-server-api/#receipts
#[ruma_enum(rename = "m.read")]
Read,

Expand All @@ -81,9 +81,8 @@ pub mod v3 {
/// This read receipt is not federated so only the user and their homeserver
/// are aware of it.
///
/// [private read receipt]: https://github.com/matrix-org/matrix-spec-proposals/pull/2285
#[cfg(feature = "unstable-msc2285")]
#[ruma_enum(rename = "org.matrix.msc2285.read.private", alias = "m.read.private")]
/// [private read receipt]: https://spec.matrix.org/v1.4/client-server-api/#private-read-receipts
#[ruma_enum(rename = "m.read.private")]
ReadPrivate,

/// A [fully read marker].
Expand All @@ -93,8 +92,7 @@ pub mod v3 {
/// This is actually not a receipt, but a piece of room account data. It is
/// provided here for convenience.
///
/// [fully read marker]: https://spec.matrix.org/v1.3/client-server-api/#fully-read-markers
#[cfg(feature = "unstable-msc2285")]
/// [fully read marker]: https://spec.matrix.org/v1.4/client-server-api/#fully-read-markers
#[ruma_enum(rename = "m.fully_read")]
FullyRead,

Expand Down
5 changes: 1 addition & 4 deletions crates/ruma/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,7 @@ unstable-extensible-events = [
]
unstable-msc1767 = ["ruma-common/unstable-msc1767"]
unstable-msc2246 = ["ruma-client-api?/unstable-msc2246"]
unstable-msc2285 = [
"ruma-client-api?/unstable-msc2285",
"ruma-common/unstable-msc2285"
]
unstable-msc2285 = ["ruma-common/unstable-msc2285"]
unstable-msc2448 = [
"ruma-client-api?/unstable-msc2448",
"ruma-common/unstable-msc2448",
Expand Down

0 comments on commit 4898203

Please sign in to comment.