common: Add support for private read receipts
According to MSC2285
This commit is contained in:
parent
2f96fa5548
commit
635480796d
@ -25,6 +25,7 @@ Breaking changes:
|
||||
* Make identifiers matrix URI constructors generic over owned parameters
|
||||
* Split `RoomId` matrix URI constructors between methods with and without routing
|
||||
* Allow to add routing servers to `RoomId::matrix_to_event_uri()`
|
||||
* Move `receipt::ReceiptType` to `events::receipt`
|
||||
|
||||
[spec]: https://github.com/matrix-org/matrix-spec-proposals/pull/3669
|
||||
|
||||
@ -46,6 +47,7 @@ Improvements:
|
||||
* Can also remove rich reply fallbacks
|
||||
* Implement `From<Owned*Id>` for `identifiers::matrix_uri::MatrixId`
|
||||
* Add unstable default push rule to ignore room server ACLs events (MSC3786)
|
||||
* Add unstable support for private read receipts (MSC2285)
|
||||
|
||||
# 0.9.2
|
||||
|
||||
|
@ -35,6 +35,7 @@ unstable-pdu = []
|
||||
unstable-pre-spec = []
|
||||
unstable-sanitize = ["html5ever", "phf"]
|
||||
unstable-msc1767 = []
|
||||
unstable-msc2285 = []
|
||||
unstable-msc2448 = []
|
||||
unstable-msc2676 = []
|
||||
unstable-msc2677 = []
|
||||
|
@ -7,19 +7,15 @@ use std::{
|
||||
ops::{Deref, DerefMut},
|
||||
};
|
||||
|
||||
use ruma_macros::EventContent;
|
||||
use ruma_macros::{EventContent, OrdAsRefStr, PartialEqAsRefStr, PartialOrdAsRefStr, StringEnum};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
receipt::ReceiptType, EventId, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedUserId, UserId,
|
||||
};
|
||||
use crate::{EventId, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedUserId, PrivOwnedStr, UserId};
|
||||
|
||||
/// The content of an `m.receipt` event.
|
||||
///
|
||||
/// A mapping of event ID to a collection of receipts for this event ID. The event ID is the ID of
|
||||
/// the event being acknowledged and *not* an ID for the receipt itself.
|
||||
///
|
||||
/// Informs the client who has read a message specified by it's event id.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
|
||||
#[allow(clippy::exhaustive_structs)]
|
||||
#[ruma_event(type = "m.receipt", kind = EphemeralRoom)]
|
||||
@ -56,6 +52,45 @@ impl DerefMut for ReceiptEventContent {
|
||||
/// A collection of receipts.
|
||||
pub type Receipts = BTreeMap<ReceiptType, UserReceipts>;
|
||||
|
||||
/// The type of receipt.
|
||||
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
|
||||
#[derive(Clone, Debug, PartialOrdAsRefStr, OrdAsRefStr, PartialEqAsRefStr, Eq, StringEnum)]
|
||||
#[non_exhaustive]
|
||||
pub enum ReceiptType {
|
||||
/// A [public read receipt].
|
||||
///
|
||||
/// Indicates that the given event has been presented to the user. It is
|
||||
/// also the point from where the unread notifications count is computed.
|
||||
///
|
||||
/// This receipt is federated to other users.
|
||||
///
|
||||
/// If both `Read` and `ReadPrivate` are present, the one that references
|
||||
/// the most recent event is used to get the latest read receipt.
|
||||
///
|
||||
/// [public read receipt]: https://spec.matrix.org/v1.3/client-server-api/#receipts
|
||||
#[ruma_enum(rename = "m.read")]
|
||||
Read,
|
||||
|
||||
/// A [private read receipt].
|
||||
///
|
||||
/// Indicates that the given event has been presented to the user. It is
|
||||
/// also the point from where the unread notifications count is computed.
|
||||
///
|
||||
/// This read receipt is not federated so only the user and their homeserver
|
||||
/// are aware of it.
|
||||
///
|
||||
/// If both `Read` and `ReadPrivate` are present, the one that references
|
||||
/// the most recent event is used to get the latest read receipt.
|
||||
///
|
||||
/// [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")]
|
||||
ReadPrivate,
|
||||
|
||||
#[doc(hidden)]
|
||||
_Custom(PrivOwnedStr),
|
||||
}
|
||||
|
||||
/// A mapping of user ID to receipt.
|
||||
///
|
||||
/// The user ID is the entity who sent this receipt.
|
||||
|
@ -1,7 +1,9 @@
|
||||
use assert_matches::assert_matches;
|
||||
use js_int::uint;
|
||||
use maplit::btreemap;
|
||||
use ruma_common::{event_id, receipt::ReceiptType, room_id, user_id, MilliSecondsSinceUnixEpoch};
|
||||
use ruma_common::{
|
||||
event_id, events::receipt::ReceiptType, room_id, user_id, MilliSecondsSinceUnixEpoch,
|
||||
};
|
||||
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};
|
||||
|
||||
use ruma_common::events::{
|
||||
|
@ -118,6 +118,7 @@ unstable-pre-spec = [
|
||||
unstable-sanitize = ["ruma-common/unstable-sanitize"]
|
||||
unstable-msc1767 = ["ruma-common/unstable-msc1767"]
|
||||
unstable-msc2246 = ["ruma-client-api?/unstable-msc2246"]
|
||||
unstable-msc2285 = ["ruma-common/unstable-msc2285"]
|
||||
unstable-msc2448 = [
|
||||
"ruma-client-api?/unstable-msc2448",
|
||||
"ruma-common/unstable-msc2448",
|
||||
@ -160,6 +161,7 @@ __ci = [
|
||||
"unstable-pre-spec",
|
||||
"unstable-sanitize",
|
||||
"unstable-msc1767",
|
||||
"unstable-msc2285",
|
||||
"unstable-msc2448",
|
||||
"unstable-msc2666",
|
||||
"unstable-msc2654",
|
||||
|
Loading…
x
Reference in New Issue
Block a user