client-api: Update push endpoints to the new API standards
This commit is contained in:
parent
bedffcd45a
commit
de22a06976
@ -14,10 +14,11 @@ ruma_api! {
|
||||
requires_authentication: true,
|
||||
}
|
||||
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
request: {
|
||||
/// The scope to delete from. 'global' to specify global rules.
|
||||
#[ruma_api(path)]
|
||||
pub scope: String,
|
||||
pub scope: &'a str,
|
||||
|
||||
/// The kind of rule
|
||||
#[ruma_api(path)]
|
||||
@ -25,10 +26,26 @@ ruma_api! {
|
||||
|
||||
/// The identifier for the rule.
|
||||
#[ruma_api(path)]
|
||||
pub rule_id: String,
|
||||
pub rule_id: &'a str,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
response: {}
|
||||
|
||||
error: crate::Error
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
/// Creates a new `Request` with the given scope, kind and rule ID.
|
||||
pub fn new(scope: &'a str, kind: RuleKind, rule_id: &'a str) -> Self {
|
||||
Self { scope, kind, rule_id }
|
||||
}
|
||||
}
|
||||
|
||||
impl Response {
|
||||
/// Creates an empty `Response`.
|
||||
pub fn new() -> Self {
|
||||
Self
|
||||
}
|
||||
}
|
||||
|
@ -19,11 +19,13 @@ ruma_api! {
|
||||
requires_authentication: true,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
request: {
|
||||
/// Pagination token given to retrieve the next set of events.
|
||||
#[ruma_api(query)]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub from: Option<String>,
|
||||
pub from: Option<&'a str>,
|
||||
|
||||
/// Limit on the number of events to return in this request.
|
||||
#[ruma_api(query)]
|
||||
@ -34,9 +36,10 @@ ruma_api! {
|
||||
/// where the notification had the 'highlight' tweak set.
|
||||
#[ruma_api(query)]
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub only: Option<String>
|
||||
pub only: Option<&'a str>
|
||||
}
|
||||
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
response: {
|
||||
/// The token to supply in the from param of the next /notifications request in order
|
||||
/// to request more events. If this is absent, there are no more results.
|
||||
@ -51,8 +54,23 @@ ruma_api! {
|
||||
error: crate::Error
|
||||
}
|
||||
|
||||
/// Represents a notification
|
||||
impl<'a> Request<'a> {
|
||||
/// Creates an empty `Request`.
|
||||
pub fn new() -> Self {
|
||||
Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
impl Response {
|
||||
/// Creates a new `Response` with the given notifications.
|
||||
pub fn new(notifications: Vec<Raw<Notification>>) -> Self {
|
||||
Self { next_token: None, notifications }
|
||||
}
|
||||
}
|
||||
|
||||
/// Represents a notification.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
pub struct Notification {
|
||||
/// The actions to perform when the conditions for this rule are met.
|
||||
pub actions: Vec<Action>,
|
||||
@ -71,7 +89,21 @@ pub struct Notification {
|
||||
/// The ID of the room in which the event was posted.
|
||||
pub room_id: RoomId,
|
||||
|
||||
/// The time at which the event notification was sent, in milliseconds.
|
||||
/// The time at which the event notification was sent.
|
||||
#[serde(with = "ruma_serde::time::ms_since_unix_epoch")]
|
||||
pub ts: SystemTime,
|
||||
}
|
||||
|
||||
impl Notification {
|
||||
/// Creates a new `Notification` with the given actions, event, read flag, room ID and
|
||||
/// timestamp.
|
||||
pub fn new(
|
||||
actions: Vec<Action>,
|
||||
event: Raw<AnyEvent>,
|
||||
read: bool,
|
||||
room_id: RoomId,
|
||||
ts: SystemTime,
|
||||
) -> Self {
|
||||
Self { actions, event, profile_tag: None, read, room_id, ts }
|
||||
}
|
||||
}
|
||||
|
@ -14,8 +14,11 @@ ruma_api! {
|
||||
requires_authentication: true,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
request: {}
|
||||
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
response: {
|
||||
/// An array containing the current pushers for the user.
|
||||
pub pushers: Vec<Pusher>
|
||||
@ -23,3 +26,17 @@ ruma_api! {
|
||||
|
||||
error: crate::Error
|
||||
}
|
||||
|
||||
impl Request {
|
||||
/// Creates an empty `Request`.
|
||||
pub fn new() -> Self {
|
||||
Self
|
||||
}
|
||||
}
|
||||
|
||||
impl Response {
|
||||
/// Creates a new `Response` with the given pushers.
|
||||
pub fn new(pushers: Vec<Pusher>) -> Self {
|
||||
Self { pushers }
|
||||
}
|
||||
}
|
||||
|
@ -15,20 +15,22 @@ ruma_api! {
|
||||
requires_authentication: true,
|
||||
}
|
||||
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
request: {
|
||||
/// The scope to fetch rules from. 'global' to specify global rules.
|
||||
#[ruma_api(path)]
|
||||
pub scope: String,
|
||||
pub scope: &'a str,
|
||||
|
||||
/// The kind of rule
|
||||
/// The kind of rule.
|
||||
#[ruma_api(path)]
|
||||
pub kind: RuleKind,
|
||||
|
||||
/// The identifier for the rule.
|
||||
#[ruma_api(path)]
|
||||
pub rule_id: String,
|
||||
pub rule_id: &'a str,
|
||||
}
|
||||
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
response: {
|
||||
/// The specific push rule.
|
||||
#[ruma_api(body)]
|
||||
@ -37,3 +39,17 @@ ruma_api! {
|
||||
|
||||
error: crate::Error
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
/// Creates a new `Request` with the given scope, rule kind and rule ID.
|
||||
pub fn new(scope: &'a str, kind: RuleKind, rule_id: &'a str) -> Self {
|
||||
Self { scope, kind, rule_id }
|
||||
}
|
||||
}
|
||||
|
||||
impl Response {
|
||||
/// Creates a new `Response` with the given rule.
|
||||
pub fn new(rule: AnyPushRule) -> Self {
|
||||
Self { rule }
|
||||
}
|
||||
}
|
||||
|
@ -15,10 +15,11 @@ ruma_api! {
|
||||
requires_authentication: true,
|
||||
}
|
||||
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
request: {
|
||||
/// The scope to fetch a rule from. 'global' to specify global rules.
|
||||
#[ruma_api(path)]
|
||||
pub scope: String,
|
||||
pub scope: &'a str,
|
||||
|
||||
/// The kind of rule
|
||||
#[ruma_api(path)]
|
||||
@ -26,9 +27,10 @@ ruma_api! {
|
||||
|
||||
/// The identifier for the rule.
|
||||
#[ruma_api(path)]
|
||||
pub rule_id: String,
|
||||
pub rule_id: &'a str,
|
||||
}
|
||||
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
response: {
|
||||
/// The actions to perform for this rule.
|
||||
pub actions: Vec<Action>
|
||||
@ -36,3 +38,17 @@ ruma_api! {
|
||||
|
||||
error: crate::Error
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
/// Creates a new `Request` with the given scope, kind and rule ID.
|
||||
pub fn new(scope: &'a str, kind: RuleKind, rule_id: &'a str) -> Self {
|
||||
Self { scope, kind, rule_id }
|
||||
}
|
||||
}
|
||||
|
||||
impl Response {
|
||||
/// Creates a new `Repsonse` with the given actions.
|
||||
pub fn new(actions: Vec<Action>) -> Self {
|
||||
Self { actions }
|
||||
}
|
||||
}
|
||||
|
@ -14,10 +14,11 @@ ruma_api! {
|
||||
requires_authentication: true,
|
||||
}
|
||||
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
request: {
|
||||
/// The scope to fetch a rule from. 'global' to specify global rules.
|
||||
#[ruma_api(path)]
|
||||
pub scope: String,
|
||||
pub scope: &'a str,
|
||||
|
||||
/// The kind of rule
|
||||
#[ruma_api(path)]
|
||||
@ -25,13 +26,28 @@ ruma_api! {
|
||||
|
||||
/// The identifier for the rule.
|
||||
#[ruma_api(path)]
|
||||
pub rule_id: String,
|
||||
pub rule_id: &'a str,
|
||||
}
|
||||
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
response: {
|
||||
/// Whether the push rule is enabled or not.
|
||||
pub enabled: bool
|
||||
pub enabled: bool,
|
||||
}
|
||||
|
||||
error: crate::Error
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
/// Creates a new `Request` with the given scope, rule kind and rule ID.
|
||||
pub fn new(scope: &'a str, kind: RuleKind, rule_id: &'a str) -> Self {
|
||||
Self { scope, kind, rule_id }
|
||||
}
|
||||
}
|
||||
|
||||
impl Response {
|
||||
/// Creates a new `Response` with the given enabled flag.
|
||||
pub fn new(enabled: bool) -> Self {
|
||||
Self { enabled }
|
||||
}
|
||||
}
|
||||
|
@ -13,12 +13,29 @@ ruma_api! {
|
||||
requires_authentication: true,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
request: {}
|
||||
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
response: {
|
||||
/// The global ruleset
|
||||
/// The global ruleset.
|
||||
pub global: Ruleset,
|
||||
}
|
||||
|
||||
error: crate::Error
|
||||
}
|
||||
|
||||
impl Request {
|
||||
/// Creates an empty `Request`.
|
||||
pub fn new() -> Self {
|
||||
Self
|
||||
}
|
||||
}
|
||||
|
||||
impl Response {
|
||||
/// Creates a new `Response` with the given global ruleset.
|
||||
pub fn new(global: Ruleset) -> Self {
|
||||
Self { global }
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,11 @@ ruma_api! {
|
||||
requires_authentication: true,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
request: {}
|
||||
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
response: {
|
||||
/// The global ruleset.
|
||||
#[ruma_api(body)]
|
||||
@ -23,3 +26,17 @@ ruma_api! {
|
||||
|
||||
error: crate::Error
|
||||
}
|
||||
|
||||
impl Request {
|
||||
/// Creates an empty `Request`.
|
||||
pub fn new() -> Self {
|
||||
Self
|
||||
}
|
||||
}
|
||||
|
||||
impl Response {
|
||||
/// Creates a new `Response` with the given global ruleset.
|
||||
pub fn new(global: Ruleset) -> Self {
|
||||
Self { global }
|
||||
}
|
||||
}
|
||||
|
@ -14,19 +14,36 @@ ruma_api! {
|
||||
requires_authentication: true,
|
||||
}
|
||||
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
request: {
|
||||
/// The pusher to configure
|
||||
/// The pusher to configure.
|
||||
#[serde(flatten)]
|
||||
pub pusher: Pusher,
|
||||
|
||||
/// Controls if another pusher with the same pushkey and app id should be created.
|
||||
/// See the spec for details.
|
||||
#[serde(default)]
|
||||
pub append: bool
|
||||
|
||||
///
|
||||
/// Defaults to `false`. See the spec for more details.
|
||||
#[serde(default, skip_serializing_if = "ruma_serde::is_default")]
|
||||
pub append: bool,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
response: {}
|
||||
|
||||
error: crate::Error
|
||||
}
|
||||
|
||||
impl Request {
|
||||
/// Creates a new `Request` with the given pusher.
|
||||
pub fn new(pusher: Pusher) -> Self {
|
||||
Self { pusher, append: false }
|
||||
}
|
||||
}
|
||||
|
||||
impl Response {
|
||||
/// Creates an empty `Response`.
|
||||
pub fn new() -> Self {
|
||||
Self
|
||||
}
|
||||
}
|
||||
|
@ -15,10 +15,11 @@ ruma_api! {
|
||||
requires_authentication: true,
|
||||
}
|
||||
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
request: {
|
||||
/// The scope to set the rule in. 'global' to specify global rules.
|
||||
#[ruma_api(path)]
|
||||
pub scope: String,
|
||||
pub scope: &'a str,
|
||||
|
||||
/// The kind of rule
|
||||
#[ruma_api(path)]
|
||||
@ -26,17 +27,17 @@ ruma_api! {
|
||||
|
||||
/// The identifier for the rule.
|
||||
#[ruma_api(path)]
|
||||
pub rule_id: String,
|
||||
pub rule_id: &'a str,
|
||||
|
||||
/// Use 'before' with a rule_id as its value to make the new rule the next-most important
|
||||
/// rule with respect to the given user defined rule.
|
||||
#[ruma_api(query)]
|
||||
pub before: Option<String>,
|
||||
pub before: Option<&'a str>,
|
||||
|
||||
/// This makes the new rule the next-less important rule relative to the given user defined
|
||||
/// rule.
|
||||
#[ruma_api(query)]
|
||||
pub after: Option<String>,
|
||||
pub after: Option<&'a str>,
|
||||
|
||||
/// The actions to perform when this rule is matched.
|
||||
pub actions: Vec<Action>,
|
||||
@ -49,10 +50,35 @@ ruma_api! {
|
||||
|
||||
/// The glob-style pattern to match against. Only applicable to content rules.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub pattern: Option<String>,
|
||||
pub pattern: Option<&'a str>,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
response: {}
|
||||
|
||||
error: crate::Error
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
/// Creates a new `Request` with the given scope, rule kind, rule ID and actions.
|
||||
pub fn new(scope: &'a str, kind: RuleKind, rule_id: &'a str, actions: Vec<Action>) -> Self {
|
||||
Self {
|
||||
scope,
|
||||
kind,
|
||||
rule_id,
|
||||
before: None,
|
||||
after: None,
|
||||
actions,
|
||||
conditions: Vec::new(),
|
||||
pattern: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Response {
|
||||
/// Creates an empty `Response`.
|
||||
pub fn new() -> Self {
|
||||
Self
|
||||
}
|
||||
}
|
||||
|
@ -15,10 +15,11 @@ ruma_api! {
|
||||
requires_authentication: true,
|
||||
}
|
||||
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
request: {
|
||||
/// The scope to fetch a rule from. 'global' to specify global rules.
|
||||
#[ruma_api(path)]
|
||||
pub scope: String,
|
||||
pub scope: &'a str,
|
||||
|
||||
/// The kind of rule
|
||||
#[ruma_api(path)]
|
||||
@ -26,13 +27,29 @@ ruma_api! {
|
||||
|
||||
/// The identifier for the rule.
|
||||
#[ruma_api(path)]
|
||||
pub rule_id: String,
|
||||
pub rule_id: &'a str,
|
||||
|
||||
/// The actions to perform for this rule
|
||||
pub actions: Vec<Action>
|
||||
pub actions: Vec<Action>,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
response: {}
|
||||
|
||||
error: crate::Error
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
/// Creates a new `Request` with the given scope, rule kind, rule ID and actions.
|
||||
pub fn new(scope: &'a str, kind: RuleKind, rule_id: &'a str, actions: Vec<Action>) -> Self {
|
||||
Self { scope, kind, rule_id, actions }
|
||||
}
|
||||
}
|
||||
|
||||
impl Response {
|
||||
/// Creates an empty `Response`.
|
||||
pub fn new() -> Self {
|
||||
Self
|
||||
}
|
||||
}
|
||||
|
@ -14,10 +14,11 @@ ruma_api! {
|
||||
requires_authentication: true,
|
||||
}
|
||||
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
request: {
|
||||
/// The scope to fetch a rule from. 'global' to specify global rules.
|
||||
#[ruma_api(path)]
|
||||
pub scope: String,
|
||||
pub scope: &'a str,
|
||||
|
||||
/// The kind of rule
|
||||
#[ruma_api(path)]
|
||||
@ -25,13 +26,39 @@ ruma_api! {
|
||||
|
||||
/// The identifier for the rule.
|
||||
#[ruma_api(path)]
|
||||
pub rule_id: String,
|
||||
pub rule_id: &'a str,
|
||||
|
||||
/// Whether the push rule is enabled or not.
|
||||
pub enabled: bool
|
||||
pub enabled: bool,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
response: {}
|
||||
|
||||
error: crate::Error
|
||||
}
|
||||
|
||||
impl<'a> Request<'a> {
|
||||
/// Creates a new `Request` with the given scope, rule kind, rule ID and enabled flag.
|
||||
pub fn new(scope: &'a str, kind: RuleKind, rule_id: &'a str, enabled: bool) -> Self {
|
||||
Self { scope, kind, rule_id, enabled }
|
||||
}
|
||||
|
||||
/// Creates a new `Request` to enable the given rule.
|
||||
pub fn enable(scope: &'a str, kind: RuleKind, rule_id: &'a str) -> Self {
|
||||
Self::new(scope, kind, rule_id, true)
|
||||
}
|
||||
|
||||
/// Creates a new `Request` to disable the given rule.
|
||||
pub fn disable(scope: &'a str, kind: RuleKind, rule_id: &'a str) -> Self {
|
||||
Self::new(scope, kind, rule_id, false)
|
||||
}
|
||||
}
|
||||
|
||||
impl Response {
|
||||
/// Creates an empty `Response`.
|
||||
pub fn new() -> Self {
|
||||
Self
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user