Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions crates/ruma-client-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ Breaking changes:

Improvements:

- Add `M_INVITE_BLOCKED` candidate error code proposed by
[MSC4380](https://github.com/matrix-org/matrix-spec-proposals/pull/4380)
sharing an unstable prefix with the preceding
[MSC4155](https://github.com/matrix-org/matrix-spec-proposals/pull/4155).

- Added support for the sliding sync extension for thread subscriptions, as well as the
accompanying endpoint, both from experimental MSC4308.
- Added support for the experiment MSC4306 thread subscription endpoints.
Expand Down
1 change: 1 addition & 0 deletions crates/ruma-client-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ unstable-msc4222 = []
# Thread subscription support.
unstable-msc4306 = []
unstable-msc4308 = []
unstable-msc4380 = ["ruma-common/unstable-msc4380", "ruma-events/unstable-msc4380"]

[dependencies]
as_variant = { workspace = true }
Expand Down
19 changes: 19 additions & 0 deletions crates/ruma-client-api/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ pub enum ErrorKind {
/// The desired user name is not valid.
InvalidUsername,

/// `M_INVITE_BLOCKED`
///
/// The invite was interdicted by moderation tools or configured access controls without having
/// been witnessed by the invitee.
#[cfg(feature = "unstable-msc4380")]
InviteBlocked,

/// `M_LIMIT_EXCEEDED`
///
/// The request has been refused due to [rate limiting]: too many requests have been sent in a
Expand Down Expand Up @@ -453,6 +460,8 @@ impl ErrorKind {
ErrorKind::InvalidParam => ErrorCode::InvalidParam,
ErrorKind::InvalidRoomState => ErrorCode::InvalidRoomState,
ErrorKind::InvalidUsername => ErrorCode::InvalidUsername,
#[cfg(feature = "unstable-msc4380")]
ErrorKind::InviteBlocked => ErrorCode::InviteBlocked,
ErrorKind::LimitExceeded { .. } => ErrorCode::LimitExceeded,
ErrorKind::MissingParam => ErrorCode::MissingParam,
ErrorKind::MissingToken => ErrorCode::MissingToken,
Expand Down Expand Up @@ -633,6 +642,16 @@ pub enum ErrorCode {
/// The desired user name is not valid.
InvalidUsername,

/// `M_INVITE_BLOCKED`
///
/// The invite was interdicted by moderation tools or configured access controls without having
/// been witnessed by the invitee.
///
/// Unstable prefix intentionally shared with MSC4155 for compatibility.
#[cfg(feature = "unstable-msc4380")]
#[ruma_enum(rename = "ORG.MATRIX.MSC4155.INVITE_BLOCKED")]
InviteBlocked,

/// `M_LIMIT_EXCEEDED`
///
/// The request has been refused due to [rate limiting]: too many requests have been sent in a
Expand Down
2 changes: 2 additions & 0 deletions crates/ruma-client-api/src/error/kind_serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ impl<'de> Visitor<'de> for ErrorKindVisitor {
ErrorCode::InvalidParam => ErrorKind::InvalidParam,
ErrorCode::InvalidRoomState => ErrorKind::InvalidRoomState,
ErrorCode::InvalidUsername => ErrorKind::InvalidUsername,
#[cfg(feature = "unstable-msc4380")]
ErrorCode::InviteBlocked => ErrorKind::InviteBlocked,
ErrorCode::LimitExceeded => ErrorKind::LimitExceeded {
retry_after: retry_after_ms
.map(from_json_value::<UInt>)
Expand Down
2 changes: 1 addition & 1 deletion crates/ruma-client-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//! [client-api]: https://spec.matrix.org/latest/client-server-api/

#![cfg(any(feature = "client", feature = "server"))]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![warn(missing_docs)]

pub mod account;
Expand Down
1 change: 0 additions & 1 deletion crates/ruma-client-api/src/membership/invite_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
pub mod v3 {
//! `/v3/` ([spec (MXID)][spec-mxid], [spec (3PID)][spec-3pid])
//!
//! This endpoint has two forms: one to invite a user
//! [by their Matrix identifier][spec-mxid], and one to invite a user
//! [by their third party identifier][spec-3pid].
//!
Expand Down
4 changes: 4 additions & 0 deletions crates/ruma-common/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Improvements:

- Add `M_INVITE_BLOCKED` candidate error code proposed by
[MSC4380](https://github.com/matrix-org/matrix-spec-proposals/pull/4380).
- Add `MatrixVersion::V1_16`
- Remove support for the `org.matrix.hydra.11` room version and the
corresponding `unstable-hydra` cargo feature. It should only have been used
Expand Down Expand Up @@ -87,6 +89,8 @@ Bug fix:

Improvements:

- Add `org.matrix.msc4380` unstable feature support to `/versions`.

- Implement the `Zeroize` trait for the `Base64` type.
- `ProtocolInstance` has an `instance_id` field, due to a clarification in the
spec.
Expand Down
1 change: 1 addition & 0 deletions crates/ruma-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ unstable-msc4186 = []
# Thread subscriptions.
unstable-msc4306 = []
unstable-msc4361 = []
unstable-msc4380 = []

# Allow IDs to exceed 255 bytes.
compat-arbitrary-length-ids = [
Expand Down
9 changes: 9 additions & 0 deletions crates/ruma-common/src/api/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1265,6 +1265,15 @@ pub enum FeatureFlag {
#[ruma_enum(rename = "org.matrix.simplified_msc3575")]
Msc4186,

/// `org.matrix.msc4380_invite_permission_config` ([MSC])
///
/// Invite Blocking.
///
/// [MSC]: https://github.com/matrix-org/matrix-spec-proposals/pull/4380
#[cfg(feature = "unstable-msc4380")]
#[ruma_enum(rename = "org.matrix.msc4380")]
Msc4380,

#[doc(hidden)]
_Custom(PrivOwnedStr),
}
Expand Down
3 changes: 3 additions & 0 deletions crates/ruma-events/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Breaking changes:

Improvements:

- Add unstable support for the `m.invite_permission_config` account data event which blocks
invites to a user, wholesale: ([MSC4380](https://github.com/matrix-org/matrix-spec-proposals/pull/4380)).

- Add support for the room account data `m.space_order` event which powers top
level space ordering as per [MSC3230](https://github.com/matrix-org/matrix-spec-proposals/pull/3230).
- Add `m.rtc.notification` event support and deprecate the (non MSC conformant)
Expand Down
1 change: 1 addition & 0 deletions crates/ruma-events/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ unstable-msc4319 = []
unstable-msc4310 = []
unstable-msc4334 = ["dep:language-tags"]
unstable-msc4359 = []
unstable-msc4380 = ["ruma-common/unstable-msc4380"]
unstable-msc3230 = []

# Allow some mandatory fields to be missing, defaulting them to an empty string
Expand Down
3 changes: 3 additions & 0 deletions crates/ruma-events/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ event_enum! {
"m.push_rules" => super::push_rules,
"m.secret_storage.default_key" => super::secret_storage::default_key,
"m.secret_storage.key.*" => super::secret_storage::key,
#[cfg(feature = "unstable-msc4380")]
#[ruma_enum(ident = InvitePermissionConfig, alias = "m.invite_permission_config")]
"org.matrix.msc4380.invite_permission_config" => super::invite_permission_config,
#[cfg(feature = "unstable-msc4278")]
"m.media_preview_config" => super::media_preview_config,
#[cfg(feature = "unstable-msc4278")]
Expand Down
67 changes: 67 additions & 0 deletions crates/ruma-events/src/invite_permission_config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//! Types for the [`m.invite_permission_config`] account data event.
//!
//! [`m.invite_permission_config`]: https://github.com/matrix-org/matrix-spec-proposals/pull/4380

use ruma_macros::EventContent;
use serde::{Deserialize, Serialize};

/// The content of an `m.invite_permission_config` event.
///
/// A single property: `block_all`.
#[derive(Clone, Debug, Default, Deserialize, Serialize, EventContent)]
#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
#[ruma_event(
kind = GlobalAccountData,
type = "org.matrix.msc4380.invite_permission_config",
alias = "m.invite_permission_config",
)]
pub struct InvitePermissionConfigEventContent {
/// When set to true, indicates that the user does not wish to receive *any* room invites, and
/// they should be blocked.
#[serde(default)]
#[serde(deserialize_with = "ruma_common::serde::default_on_error")]
pub block_all: bool,
}

impl InvitePermissionConfigEventContent {
/// Creates a new `InvitePermissionConfigEventContent` from the desired boolean state.
pub fn new(block_all: bool) -> Self {
Self { block_all }
}
}

#[cfg(test)]
mod tests {
use assert_matches2::assert_matches;
use serde_json::{from_value as from_json_value, json, to_value as to_json_value};

use super::InvitePermissionConfigEventContent;
use crate::AnyGlobalAccountDataEvent;

#[test]
fn serialization() {
let invite_permission_config = InvitePermissionConfigEventContent::new(true);

let json = json!({
"block_all": true
});

assert_eq!(to_json_value(invite_permission_config).unwrap(), json);
}

#[test]
fn deserialization() {
let json = json!({
"content": {
"block_all": true
},
"type": "m.invite_permission_config"
});

assert_matches!(
from_json_value::<AnyGlobalAccountDataEvent>(json),
Ok(AnyGlobalAccountDataEvent::InvitePermissionConfig(ev))
);
assert!(ev.content.block_all);
}
}
2 changes: 2 additions & 0 deletions crates/ruma-events/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ pub mod image_pack;
pub mod key;
#[cfg(feature = "unstable-msc3488")]
pub mod location;
#[cfg(feature = "unstable-msc4380")]
pub mod invite_permission_config;
pub mod marked_unread;
#[cfg(feature = "unstable-msc4278")]
pub mod media_preview_config;
Expand Down
6 changes: 6 additions & 0 deletions crates/ruma/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,11 @@ unstable-msc4310 = ["ruma-events?/unstable-msc4310"]
unstable-msc4334 = ["ruma-events?/unstable-msc4334", "dep:language-tags"]
unstable-msc4359 = ["ruma-events?/unstable-msc4359"]
unstable-msc4361 = ["ruma-common/unstable-msc4361"]
unstable-msc4380 = [
"ruma-client-api?/unstable-msc4380",
"ruma-common/unstable-msc4380",
"ruma-events?/unstable-msc4380",
]
unstable-msc3230 = ["ruma-events?/unstable-msc3230"]

# Private features, only used in test / benchmarking code
Expand Down Expand Up @@ -310,6 +315,7 @@ __unstable-mscs = [
"unstable-msc4319",
"unstable-msc4334",
"unstable-msc4359",
"unstable-msc4380",
"unstable-msc3230",
]
__ci = ["full", "compat-upload-signatures", "__unstable-mscs"]
Expand Down