Skip to content

Commit eb4ccd1

Browse files
impl MSC4380
1 parent 0130f6a commit eb4ccd1

15 files changed

Lines changed: 124 additions & 2 deletions

File tree

crates/ruma-client-api/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ Breaking changes:
5454

5555
Improvements:
5656

57+
- Add `M_INVITE_BLOCKED` candidate error code proposed by
58+
[MSC4380](https://github.com/matrix-org/matrix-spec-proposals/pull/4380)
59+
sharing an unstable prefix with the preceding
60+
[MSC4155](https://github.com/matrix-org/matrix-spec-proposals/pull/4155).
61+
5762
- Added support for the sliding sync extension for thread subscriptions, as well as the
5863
accompanying endpoint, both from experimental MSC4308.
5964
- Added support for the experiment MSC4306 thread subscription endpoints.

crates/ruma-client-api/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ unstable-msc4222 = []
5757
# Thread subscription support.
5858
unstable-msc4306 = []
5959
unstable-msc4308 = []
60+
unstable-msc4380 = ["ruma-common/unstable-msc4380", "ruma-events/unstable-msc4380"]
6061

6162
[dependencies]
6263
as_variant = { workspace = true }

crates/ruma-client-api/src/error.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,13 @@ pub enum ErrorKind {
169169
/// The desired user name is not valid.
170170
InvalidUsername,
171171

172+
/// `M_INVITE_BLOCKED`
173+
///
174+
/// The invite was interdicted by moderation tools or configured access controls without having
175+
/// been witnessed by the invitee.
176+
#[cfg(feature = "unstable-msc4380")]
177+
InviteBlocked,
178+
172179
/// `M_LIMIT_EXCEEDED`
173180
///
174181
/// The request has been refused due to [rate limiting]: too many requests have been sent in a
@@ -453,6 +460,8 @@ impl ErrorKind {
453460
ErrorKind::InvalidParam => ErrorCode::InvalidParam,
454461
ErrorKind::InvalidRoomState => ErrorCode::InvalidRoomState,
455462
ErrorKind::InvalidUsername => ErrorCode::InvalidUsername,
463+
#[cfg(feature = "unstable-msc4380")]
464+
ErrorKind::InviteBlocked => ErrorCode::InviteBlocked,
456465
ErrorKind::LimitExceeded { .. } => ErrorCode::LimitExceeded,
457466
ErrorKind::MissingParam => ErrorCode::MissingParam,
458467
ErrorKind::MissingToken => ErrorCode::MissingToken,
@@ -633,6 +642,16 @@ pub enum ErrorCode {
633642
/// The desired user name is not valid.
634643
InvalidUsername,
635644

645+
/// `M_INVITE_BLOCKED`
646+
///
647+
/// The invite was interdicted by moderation tools or configured access controls without having
648+
/// been witnessed by the invitee.
649+
///
650+
/// Unstable prefix intentionally shared with MSC4155 for compatibility.
651+
#[cfg(feature = "unstable-msc4380")]
652+
#[ruma_enum(rename = "ORG.MATRIX.MSC4155.INVITE_BLOCKED")]
653+
InviteBlocked,
654+
636655
/// `M_LIMIT_EXCEEDED`
637656
///
638657
/// The request has been refused due to [rate limiting]: too many requests have been sent in a

crates/ruma-client-api/src/error/kind_serde.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ impl<'de> Visitor<'de> for ErrorKindVisitor {
199199
ErrorCode::InvalidParam => ErrorKind::InvalidParam,
200200
ErrorCode::InvalidRoomState => ErrorKind::InvalidRoomState,
201201
ErrorCode::InvalidUsername => ErrorKind::InvalidUsername,
202+
#[cfg(feature = "unstable-msc4380")]
203+
ErrorCode::InviteBlocked => ErrorKind::InviteBlocked,
202204
ErrorCode::LimitExceeded => ErrorKind::LimitExceeded {
203205
retry_after: retry_after_ms
204206
.map(from_json_value::<UInt>)

crates/ruma-client-api/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//! [client-api]: https://spec.matrix.org/latest/client-server-api/
77
88
#![cfg(any(feature = "client", feature = "server"))]
9-
#![cfg_attr(docsrs, feature(doc_cfg))]
9+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
1010
#![warn(missing_docs)]
1111

1212
pub mod account;

crates/ruma-client-api/src/membership/invite_user.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
pub mod v3 {
66
//! `/v3/` ([spec (MXID)][spec-mxid], [spec (3PID)][spec-3pid])
77
//!
8-
//! This endpoint has two forms: one to invite a user
98
//! [by their Matrix identifier][spec-mxid], and one to invite a user
109
//! [by their third party identifier][spec-3pid].
1110
//!

crates/ruma-common/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Improvements:
44

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

8890
Improvements:
8991

92+
- Add `org.matrix.msc4380` unstable feature support to `/versions`.
93+
9094
- Implement the `Zeroize` trait for the `Base64` type.
9195
- `ProtocolInstance` has an `instance_id` field, due to a clarification in the
9296
spec.

crates/ruma-common/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ unstable-msc4186 = []
3838
# Thread subscriptions.
3939
unstable-msc4306 = []
4040
unstable-msc4361 = []
41+
unstable-msc4380 = []
4142

4243
# Allow IDs to exceed 255 bytes.
4344
compat-arbitrary-length-ids = [

crates/ruma-common/src/api/metadata.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,6 +1265,15 @@ pub enum FeatureFlag {
12651265
#[ruma_enum(rename = "org.matrix.simplified_msc3575")]
12661266
Msc4186,
12671267

1268+
/// `org.matrix.msc4380_invite_permission_config` ([MSC])
1269+
///
1270+
/// Invite Blocking.
1271+
///
1272+
/// [MSC]: https://github.com/matrix-org/matrix-spec-proposals/pull/4380
1273+
#[cfg(feature = "unstable-msc4380")]
1274+
#[ruma_enum(rename = "org.matrix.msc4380")]
1275+
Msc4380,
1276+
12681277
#[doc(hidden)]
12691278
_Custom(PrivOwnedStr),
12701279
}

crates/ruma-events/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ Breaking changes:
1616

1717
Improvements:
1818

19+
- Add unstable support for the `m.invite_permission_config` account data event which blocks
20+
invites to a user, wholesale: ([MSC4380](https://github.com/matrix-org/matrix-spec-proposals/pull/4380)).
21+
1922
- Add support for the room account data `m.space_order` event which powers top
2023
level space ordering as per [MSC3230](https://github.com/matrix-org/matrix-spec-proposals/pull/3230).
2124
- Add `m.rtc.notification` event support and deprecate the (non MSC conformant)

0 commit comments

Comments
 (0)