client-api: Remove RuleScope
The `global` scope is hardcoded due to a clarification in the spec.
This commit is contained in:
parent
9abafb284a
commit
1aa2eadd70
@ -12,6 +12,9 @@ Breaking changes:
|
|||||||
`ContentDisposition` instead of strings.
|
`ContentDisposition` instead of strings.
|
||||||
- Replace `server_name` on `knock::knock_room::v3::Request` and
|
- Replace `server_name` on `knock::knock_room::v3::Request` and
|
||||||
`membership::join_room_by_id_or_alias::v3::Request` with `via` as per MSC4156.
|
`membership::join_room_by_id_or_alias::v3::Request` with `via` as per MSC4156.
|
||||||
|
- Remove `RuleScope`, due to a clarification in the Matrix 1.12 where the `global`
|
||||||
|
scope is now hardcoded.
|
||||||
|
- The `push` endpoints don't take a scope anymore.
|
||||||
|
|
||||||
Improvements:
|
Improvements:
|
||||||
|
|
||||||
|
@ -8,12 +8,10 @@ use ruma_common::{
|
|||||||
HttpPusherData, PatternedPushRule, PatternedPushRuleInit, PushCondition, SimplePushRule,
|
HttpPusherData, PatternedPushRule, PatternedPushRuleInit, PushCondition, SimplePushRule,
|
||||||
SimplePushRuleInit,
|
SimplePushRuleInit,
|
||||||
},
|
},
|
||||||
serde::{JsonObject, StringEnum},
|
serde::JsonObject,
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::PrivOwnedStr;
|
|
||||||
|
|
||||||
pub mod delete_pushrule;
|
pub mod delete_pushrule;
|
||||||
pub mod get_notifications;
|
pub mod get_notifications;
|
||||||
pub mod get_pushers;
|
pub mod get_pushers;
|
||||||
@ -306,16 +304,3 @@ pub struct CustomPusherData {
|
|||||||
kind: String,
|
kind: String,
|
||||||
data: JsonObject,
|
data: JsonObject,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The scope of a push rule.
|
|
||||||
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
|
|
||||||
#[derive(Clone, PartialEq, Eq, StringEnum)]
|
|
||||||
#[ruma_enum(rename_all = "lowercase")]
|
|
||||||
#[non_exhaustive]
|
|
||||||
pub enum RuleScope {
|
|
||||||
/// The global rules.
|
|
||||||
Global,
|
|
||||||
|
|
||||||
#[doc(hidden)]
|
|
||||||
_Custom(PrivOwnedStr),
|
|
||||||
}
|
|
||||||
|
@ -1,36 +1,32 @@
|
|||||||
//! `DELETE /_matrix/client/*/pushrules/{scope}/{kind}/{ruleId}`
|
//! `DELETE /_matrix/client/*/pushrules/global/{kind}/{ruleId}`
|
||||||
//!
|
//!
|
||||||
//! This endpoint removes the push rule defined in the path.
|
//! This endpoint removes the push rule defined in the path.
|
||||||
|
|
||||||
pub mod v3 {
|
pub mod v3 {
|
||||||
//! `/v3/` ([spec])
|
//! `/v3/` ([spec])
|
||||||
//!
|
//!
|
||||||
//! [spec]: https://spec.matrix.org/latest/client-server-api/#delete_matrixclientv3pushrulesscopekindruleid
|
//! [spec]: https://spec.matrix.org/latest/client-server-api/#delete_matrixclientv3pushrulesglobalkindruleid
|
||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata,
|
metadata,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::push::{RuleKind, RuleScope};
|
use crate::push::RuleKind;
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
method: DELETE,
|
method: DELETE,
|
||||||
rate_limited: false,
|
rate_limited: false,
|
||||||
authentication: AccessToken,
|
authentication: AccessToken,
|
||||||
history: {
|
history: {
|
||||||
1.0 => "/_matrix/client/r0/pushrules/:scope/:kind/:rule_id",
|
1.0 => "/_matrix/client/r0/pushrules/global/:kind/:rule_id",
|
||||||
1.1 => "/_matrix/client/v3/pushrules/:scope/:kind/:rule_id",
|
1.1 => "/_matrix/client/v3/pushrules/global/:kind/:rule_id",
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Request type for the `delete_pushrule` endpoint.
|
/// Request type for the `delete_pushrule` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request {
|
pub struct Request {
|
||||||
/// The scope to delete from.
|
|
||||||
#[ruma_api(path)]
|
|
||||||
pub scope: RuleScope,
|
|
||||||
|
|
||||||
/// The kind of rule
|
/// The kind of rule
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub kind: RuleKind,
|
pub kind: RuleKind,
|
||||||
@ -46,9 +42,9 @@ pub mod v3 {
|
|||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl Request {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given scope, kind and rule ID.
|
/// Creates a new `Request` with the given kind and rule ID.
|
||||||
pub fn new(scope: RuleScope, kind: RuleKind, rule_id: String) -> Self {
|
pub fn new(kind: RuleKind, rule_id: String) -> Self {
|
||||||
Self { scope, kind, rule_id }
|
Self { kind, rule_id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,36 +1,32 @@
|
|||||||
//! `GET /_matrix/client/*/pushrules/{scope}/{kind}/{ruleId}`
|
//! `GET /_matrix/client/*/pushrules/global/{kind}/{ruleId}`
|
||||||
//!
|
//!
|
||||||
//! Retrieve a single specified push rule.
|
//! Retrieve a single specified push rule.
|
||||||
|
|
||||||
pub mod v3 {
|
pub mod v3 {
|
||||||
//! `/v3/` ([spec])
|
//! `/v3/` ([spec])
|
||||||
//!
|
//!
|
||||||
//! [spec]: https://spec.matrix.org/latest/client-server-api/#get_matrixclientv3pushrulesscopekindruleid
|
//! [spec]: https://spec.matrix.org/latest/client-server-api/#get_matrixclientv3pushrulesglobalkindruleid
|
||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata,
|
metadata,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::push::{PushRule, RuleKind, RuleScope};
|
use crate::push::{PushRule, RuleKind};
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
method: GET,
|
method: GET,
|
||||||
rate_limited: false,
|
rate_limited: false,
|
||||||
authentication: AccessToken,
|
authentication: AccessToken,
|
||||||
history: {
|
history: {
|
||||||
1.0 => "/_matrix/client/r0/pushrules/:scope/:kind/:rule_id",
|
1.0 => "/_matrix/client/r0/pushrules/global/:kind/:rule_id",
|
||||||
1.1 => "/_matrix/client/v3/pushrules/:scope/:kind/:rule_id",
|
1.1 => "/_matrix/client/v3/pushrules/global/:kind/:rule_id",
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Request type for the `get_pushrule` endpoint.
|
/// Request type for the `get_pushrule` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request {
|
pub struct Request {
|
||||||
/// The scope to fetch rules from.
|
|
||||||
#[ruma_api(path)]
|
|
||||||
pub scope: RuleScope,
|
|
||||||
|
|
||||||
/// The kind of rule.
|
/// The kind of rule.
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub kind: RuleKind,
|
pub kind: RuleKind,
|
||||||
@ -49,9 +45,9 @@ pub mod v3 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Request {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given scope, rule kind and rule ID.
|
/// Creates a new `Request` with the given rule kind and rule ID.
|
||||||
pub fn new(scope: RuleScope, kind: RuleKind, rule_id: String) -> Self {
|
pub fn new(kind: RuleKind, rule_id: String) -> Self {
|
||||||
Self { scope, kind, rule_id }
|
Self { kind, rule_id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
//! `GET /_matrix/client/*/pushrules/{scope}/{kind}/{ruleId}/actions`
|
//! `GET /_matrix/client/*/pushrules/global/{kind}/{ruleId}/actions`
|
||||||
//!
|
//!
|
||||||
//! This endpoint get the actions for the specified push rule.
|
//! This endpoint get the actions for the specified push rule.
|
||||||
|
|
||||||
pub mod v3 {
|
pub mod v3 {
|
||||||
//! `/v3/` ([spec])
|
//! `/v3/` ([spec])
|
||||||
//!
|
//!
|
||||||
//! [spec]: https://spec.matrix.org/latest/client-server-api/#get_matrixclientv3pushrulesscopekindruleidactions
|
//! [spec]: https://spec.matrix.org/latest/client-server-api/#get_matrixclientv3pushrulesglobalkindruleidactions
|
||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
@ -13,25 +13,21 @@ pub mod v3 {
|
|||||||
push::Action,
|
push::Action,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::push::{RuleKind, RuleScope};
|
use crate::push::RuleKind;
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
method: GET,
|
method: GET,
|
||||||
rate_limited: false,
|
rate_limited: false,
|
||||||
authentication: AccessToken,
|
authentication: AccessToken,
|
||||||
history: {
|
history: {
|
||||||
1.0 => "/_matrix/client/r0/pushrules/:scope/:kind/:rule_id/actions",
|
1.0 => "/_matrix/client/r0/pushrules/global/:kind/:rule_id/actions",
|
||||||
1.1 => "/_matrix/client/v3/pushrules/:scope/:kind/:rule_id/actions",
|
1.1 => "/_matrix/client/v3/pushrules/global/:kind/:rule_id/actions",
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Request type for the `get_pushrule_actions` endpoint.
|
/// Request type for the `get_pushrule_actions` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request {
|
pub struct Request {
|
||||||
/// The scope to fetch a rule from.
|
|
||||||
#[ruma_api(path)]
|
|
||||||
pub scope: RuleScope,
|
|
||||||
|
|
||||||
/// The kind of rule
|
/// The kind of rule
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub kind: RuleKind,
|
pub kind: RuleKind,
|
||||||
@ -49,9 +45,9 @@ pub mod v3 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Request {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given scope, kind and rule ID.
|
/// Creates a new `Request` with the given kind and rule ID.
|
||||||
pub fn new(scope: RuleScope, kind: RuleKind, rule_id: String) -> Self {
|
pub fn new(kind: RuleKind, rule_id: String) -> Self {
|
||||||
Self { scope, kind, rule_id }
|
Self { kind, rule_id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,36 +1,32 @@
|
|||||||
//! `GET /_matrix/client/*/pushrules/{scope}/{kind}/{ruleId}/enabled`
|
//! `GET /_matrix/client/*/pushrules/global/{kind}/{ruleId}/enabled`
|
||||||
//!
|
//!
|
||||||
//! This endpoint gets whether the specified push rule is enabled.
|
//! This endpoint gets whether the specified push rule is enabled.
|
||||||
|
|
||||||
pub mod v3 {
|
pub mod v3 {
|
||||||
//! `/v3/` ([spec])
|
//! `/v3/` ([spec])
|
||||||
//!
|
//!
|
||||||
//! [spec]: https://spec.matrix.org/latest/client-server-api/#get_matrixclientv3pushrulesscopekindruleidenabled
|
//! [spec]: https://spec.matrix.org/latest/client-server-api/#get_matrixclientv3pushrulesglobalkindruleidenabled
|
||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata,
|
metadata,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::push::{RuleKind, RuleScope};
|
use crate::push::RuleKind;
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
method: GET,
|
method: GET,
|
||||||
rate_limited: false,
|
rate_limited: false,
|
||||||
authentication: AccessToken,
|
authentication: AccessToken,
|
||||||
history: {
|
history: {
|
||||||
1.0 => "/_matrix/client/r0/pushrules/:scope/:kind/:rule_id/enabled",
|
1.0 => "/_matrix/client/r0/pushrules/global/:kind/:rule_id/enabled",
|
||||||
1.1 => "/_matrix/client/v3/pushrules/:scope/:kind/:rule_id/enabled",
|
1.1 => "/_matrix/client/v3/pushrules/global/:kind/:rule_id/enabled",
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Request type for the `get_pushrule_enabled` endpoint.
|
/// Request type for the `get_pushrule_enabled` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request {
|
pub struct Request {
|
||||||
/// The scope to fetch a rule from.
|
|
||||||
#[ruma_api(path)]
|
|
||||||
pub scope: RuleScope,
|
|
||||||
|
|
||||||
/// The kind of rule
|
/// The kind of rule
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub kind: RuleKind,
|
pub kind: RuleKind,
|
||||||
@ -48,9 +44,9 @@ pub mod v3 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Request {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given scope, rule kind and rule ID.
|
/// Creates a new `Request` with the given rule kind and rule ID.
|
||||||
pub fn new(scope: RuleScope, kind: RuleKind, rule_id: String) -> Self {
|
pub fn new(kind: RuleKind, rule_id: String) -> Self {
|
||||||
Self { scope, kind, rule_id }
|
Self { kind, rule_id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
pub mod v3 {
|
pub mod v3 {
|
||||||
//! `/v3/` ([spec])
|
//! `/v3/` ([spec])
|
||||||
//!
|
//!
|
||||||
//! [spec]: https://spec.matrix.org/latest/client-server-api/#get_matrixclientv3pushrules
|
//! [spec]: https://spec.matrix.org/latest/client-server-api/#get_matrixclientv3pushrulesglobal
|
||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
//! `PUT /_matrix/client/*/pushrules/{scope}/{kind}/{ruleId}`
|
//! `PUT /_matrix/client/*/pushrules/global/{kind}/{ruleId}`
|
||||||
//!
|
//!
|
||||||
//! This endpoint allows the creation and modification of push rules for this user ID.
|
//! This endpoint allows the creation and modification of push rules for this user ID.
|
||||||
|
|
||||||
pub mod v3 {
|
pub mod v3 {
|
||||||
//! `/v3/` ([spec])
|
//! `/v3/` ([spec])
|
||||||
//!
|
//!
|
||||||
//! [spec]: https://spec.matrix.org/latest/client-server-api/#put_matrixclientv3pushrulesscopekindruleid
|
//! [spec]: https://spec.matrix.org/latest/client-server-api/#put_matrixclientv3pushrulesglobalkindruleid
|
||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{response, Metadata},
|
api::{response, Metadata},
|
||||||
@ -14,15 +14,13 @@ pub mod v3 {
|
|||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::push::RuleScope;
|
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
method: PUT,
|
method: PUT,
|
||||||
rate_limited: true,
|
rate_limited: true,
|
||||||
authentication: AccessToken,
|
authentication: AccessToken,
|
||||||
history: {
|
history: {
|
||||||
1.0 => "/_matrix/client/r0/pushrules/:scope/:kind/:rule_id",
|
1.0 => "/_matrix/client/r0/pushrules/global/:kind/:rule_id",
|
||||||
1.1 => "/_matrix/client/v3/pushrules/:scope/:kind/:rule_id",
|
1.1 => "/_matrix/client/v3/pushrules/global/:kind/:rule_id",
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -30,9 +28,6 @@ pub mod v3 {
|
|||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
pub struct Request {
|
pub struct Request {
|
||||||
/// The scope to set the rule in.
|
|
||||||
pub scope: RuleScope,
|
|
||||||
|
|
||||||
/// The rule.
|
/// The rule.
|
||||||
pub rule: NewPushRule,
|
pub rule: NewPushRule,
|
||||||
|
|
||||||
@ -51,9 +46,9 @@ pub mod v3 {
|
|||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl Request {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given scope and rule.
|
/// Creates a new `Request` with the given rule.
|
||||||
pub fn new(scope: RuleScope, rule: NewPushRule) -> Self {
|
pub fn new(rule: NewPushRule) -> Self {
|
||||||
Self { scope, rule, before: None, after: None }
|
Self { rule, before: None, after: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +82,7 @@ pub mod v3 {
|
|||||||
let url = METADATA.make_endpoint_url(
|
let url = METADATA.make_endpoint_url(
|
||||||
considering_versions,
|
considering_versions,
|
||||||
base_url,
|
base_url,
|
||||||
&[&self.scope, &self.rule.kind(), &self.rule.rule_id()],
|
&[&self.rule.kind(), &self.rule.rule_id()],
|
||||||
&query_string,
|
&query_string,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
@ -147,7 +142,7 @@ pub mod v3 {
|
|||||||
after: Option<String>,
|
after: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
let (scope, kind, rule_id): (RuleScope, RuleKind, String) =
|
let (kind, rule_id): (RuleKind, String) =
|
||||||
Deserialize::deserialize(serde::de::value::SeqDeserializer::<
|
Deserialize::deserialize(serde::de::value::SeqDeserializer::<
|
||||||
_,
|
_,
|
||||||
serde::de::value::Error,
|
serde::de::value::Error,
|
||||||
@ -190,7 +185,7 @@ pub mod v3 {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(Self { scope, rule, before, after })
|
Ok(Self { rule, before, after })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//! `PUT /_matrix/client/*/pushrules/{scope}/{kind}/{ruleId}/actions`
|
//! `PUT /_matrix/client/*/pushrules/global/{kind}/{ruleId}/actions`
|
||||||
//!
|
//!
|
||||||
//! This endpoint allows clients to change the actions of a push rule. This can be used to change
|
//! This endpoint allows clients to change the actions of a push rule. This can be used to change
|
||||||
//! the actions of builtin rules.
|
//! the actions of builtin rules.
|
||||||
@ -6,7 +6,7 @@
|
|||||||
pub mod v3 {
|
pub mod v3 {
|
||||||
//! `/v3/` ([spec])
|
//! `/v3/` ([spec])
|
||||||
//!
|
//!
|
||||||
//! [spec]: https://spec.matrix.org/latest/client-server-api/#put_matrixclientv3pushrulesscopekindruleidactions
|
//! [spec]: https://spec.matrix.org/latest/client-server-api/#put_matrixclientv3pushrulesglobalkindruleidactions
|
||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
@ -14,25 +14,21 @@ pub mod v3 {
|
|||||||
push::Action,
|
push::Action,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::push::{RuleKind, RuleScope};
|
use crate::push::RuleKind;
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
method: PUT,
|
method: PUT,
|
||||||
rate_limited: false,
|
rate_limited: false,
|
||||||
authentication: AccessToken,
|
authentication: AccessToken,
|
||||||
history: {
|
history: {
|
||||||
1.0 => "/_matrix/client/r0/pushrules/:scope/:kind/:rule_id/actions",
|
1.0 => "/_matrix/client/r0/pushrules/global/:kind/:rule_id/actions",
|
||||||
1.1 => "/_matrix/client/v3/pushrules/:scope/:kind/:rule_id/actions",
|
1.1 => "/_matrix/client/v3/pushrules/global/:kind/:rule_id/actions",
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Request type for the `set_pushrule_actions` endpoint.
|
/// Request type for the `set_pushrule_actions` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request {
|
pub struct Request {
|
||||||
/// The scope to fetch a rule from.
|
|
||||||
#[ruma_api(path)]
|
|
||||||
pub scope: RuleScope,
|
|
||||||
|
|
||||||
/// The kind of rule
|
/// The kind of rule
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub kind: RuleKind,
|
pub kind: RuleKind,
|
||||||
@ -51,14 +47,9 @@ pub mod v3 {
|
|||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl Request {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given scope, rule kind, rule ID and actions.
|
/// Creates a new `Request` with the given rule kind, rule ID and actions.
|
||||||
pub fn new(
|
pub fn new(kind: RuleKind, rule_id: String, actions: Vec<Action>) -> Self {
|
||||||
scope: RuleScope,
|
Self { kind, rule_id, actions }
|
||||||
kind: RuleKind,
|
|
||||||
rule_id: String,
|
|
||||||
actions: Vec<Action>,
|
|
||||||
) -> Self {
|
|
||||||
Self { scope, kind, rule_id, actions }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,36 +1,32 @@
|
|||||||
//! `PUT /_matrix/client/*/pushrules/{scope}/{kind}/{ruleId}/enabled`
|
//! `PUT /_matrix/client/*/pushrules/global/{kind}/{ruleId}/enabled`
|
||||||
//!
|
//!
|
||||||
//! This endpoint allows clients to enable or disable the specified push rule.
|
//! This endpoint allows clients to enable or disable the specified push rule.
|
||||||
|
|
||||||
pub mod v3 {
|
pub mod v3 {
|
||||||
//! `/v3/` ([spec])
|
//! `/v3/` ([spec])
|
||||||
//!
|
//!
|
||||||
//! [spec]: https://spec.matrix.org/latest/client-server-api/#put_matrixclientv3pushrulesscopekindruleidenabled
|
//! [spec]: https://spec.matrix.org/latest/client-server-api/#put_matrixclientv3pushrulesglobalkindruleidenabled
|
||||||
|
|
||||||
use ruma_common::{
|
use ruma_common::{
|
||||||
api::{request, response, Metadata},
|
api::{request, response, Metadata},
|
||||||
metadata,
|
metadata,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::push::{RuleKind, RuleScope};
|
use crate::push::RuleKind;
|
||||||
|
|
||||||
const METADATA: Metadata = metadata! {
|
const METADATA: Metadata = metadata! {
|
||||||
method: PUT,
|
method: PUT,
|
||||||
rate_limited: false,
|
rate_limited: false,
|
||||||
authentication: AccessToken,
|
authentication: AccessToken,
|
||||||
history: {
|
history: {
|
||||||
1.0 => "/_matrix/client/r0/pushrules/:scope/:kind/:rule_id/enabled",
|
1.0 => "/_matrix/client/r0/pushrules/global/:kind/:rule_id/enabled",
|
||||||
1.1 => "/_matrix/client/v3/pushrules/:scope/:kind/:rule_id/enabled",
|
1.1 => "/_matrix/client/v3/pushrules/global/:kind/:rule_id/enabled",
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Request type for the `set_pushrule_enabled` endpoint.
|
/// Request type for the `set_pushrule_enabled` endpoint.
|
||||||
#[request(error = crate::Error)]
|
#[request(error = crate::Error)]
|
||||||
pub struct Request {
|
pub struct Request {
|
||||||
/// The scope to fetch a rule from.
|
|
||||||
#[ruma_api(path)]
|
|
||||||
pub scope: RuleScope,
|
|
||||||
|
|
||||||
/// The kind of rule
|
/// The kind of rule
|
||||||
#[ruma_api(path)]
|
#[ruma_api(path)]
|
||||||
pub kind: RuleKind,
|
pub kind: RuleKind,
|
||||||
@ -49,19 +45,19 @@ pub mod v3 {
|
|||||||
pub struct Response {}
|
pub struct Response {}
|
||||||
|
|
||||||
impl Request {
|
impl Request {
|
||||||
/// Creates a new `Request` with the given scope, rule kind, rule ID and enabled flag.
|
/// Creates a new `Request` with the given rule kind, rule ID and enabled flag.
|
||||||
pub fn new(scope: RuleScope, kind: RuleKind, rule_id: String, enabled: bool) -> Self {
|
pub fn new(kind: RuleKind, rule_id: String, enabled: bool) -> Self {
|
||||||
Self { scope, kind, rule_id, enabled }
|
Self { kind, rule_id, enabled }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new `Request` to enable the given rule.
|
/// Creates a new `Request` to enable the given rule.
|
||||||
pub fn enable(scope: RuleScope, kind: RuleKind, rule_id: String) -> Self {
|
pub fn enable(kind: RuleKind, rule_id: String) -> Self {
|
||||||
Self::new(scope, kind, rule_id, true)
|
Self::new(kind, rule_id, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new `Request` to disable the given rule.
|
/// Creates a new `Request` to disable the given rule.
|
||||||
pub fn disable(scope: RuleScope, kind: RuleKind, rule_id: String) -> Self {
|
pub fn disable(kind: RuleKind, rule_id: String) -> Self {
|
||||||
Self::new(scope, kind, rule_id, false)
|
Self::new(kind, rule_id, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user