client-api: Split push::Pusher in two

The definitions for the get and set endpoint are different.
This commit is contained in:
Jonas Platte 2021-04-18 12:25:40 +02:00
parent 10adf0c0c0
commit 9f815facc5
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
3 changed files with 62 additions and 32 deletions

View File

@ -181,36 +181,6 @@ pub enum RuleKind {
_Custom(String),
}
/// Defines a pusher.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Pusher {
/// This is a unique identifier for this pusher. Max length, 512 bytes.
pub pushkey: String,
/// The kind of the pusher. If set to None in a call to set_pusher, this
/// will delete the pusher
pub kind: Option<PusherKind>,
/// This is a reverse-DNS style identifier for the application. Max length, 64 chars.
pub app_id: String,
/// A string that will allow the user to identify what application owns this pusher.
pub app_display_name: String,
/// A string that will allow the user to identify what device owns this pusher.
pub device_display_name: String,
/// This string determines which set of device specific rules this pusher executes.
#[serde(skip_serializing_if = "Option::is_none")]
pub profile_tag: Option<String>,
/// The preferred language for receiving notifications (e.g. 'en' or 'en-US')
pub lang: String,
/// Information for the pusher implementation itself.
pub data: PusherData,
}
/// Which kind a pusher is.
#[derive(Clone, Debug, PartialEq, Eq, StringEnum)]
#[ruma_enum(rename_all = "snake_case")]

View File

@ -1,8 +1,9 @@
//! [GET /_matrix/client/r0/pushers](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-pushers)
use ruma_api::ruma_api;
use serde::{Deserialize, Serialize};
use super::Pusher;
use super::{PusherData, PusherKind};
ruma_api! {
metadata: {
@ -38,3 +39,32 @@ impl Response {
Self { pushers }
}
}
/// Defines a pusher.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Pusher {
/// This is a unique identifier for this pusher. Max length, 512 bytes.
pub pushkey: String,
/// The kind of the pusher.
pub kind: PusherKind,
/// This is a reverse-DNS style identifier for the application. Max length, 64 chars.
pub app_id: String,
/// A string that will allow the user to identify what application owns this pusher.
pub app_display_name: String,
/// A string that will allow the user to identify what device owns this pusher.
pub device_display_name: String,
/// This string determines which set of device specific rules this pusher executes.
#[serde(skip_serializing_if = "Option::is_none")]
pub profile_tag: Option<String>,
/// The preferred language for receiving notifications (e.g. 'en' or 'en-US')
pub lang: String,
/// Information for the pusher implementation itself.
pub data: PusherData,
}

View File

@ -1,8 +1,9 @@
//! [POST /_matrix/client/r0/pushers/set](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-pushers-set)
use ruma_api::ruma_api;
use serde::{Deserialize, Serialize};
use super::Pusher;
use super::{PusherData, PusherKind};
ruma_api! {
metadata: {
@ -45,3 +46,32 @@ impl Response {
Self
}
}
/// Defines a pusher.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Pusher {
/// This is a unique identifier for this pusher. Max length, 512 bytes.
pub pushkey: String,
/// The kind of the pusher. `None` deletes the pusher.
pub kind: Option<PusherKind>,
/// This is a reverse-DNS style identifier for the application. Max length, 64 chars.
pub app_id: String,
/// A string that will allow the user to identify what application owns this pusher.
pub app_display_name: String,
/// A string that will allow the user to identify what device owns this pusher.
pub device_display_name: String,
/// This string determines which set of device specific rules this pusher executes.
#[serde(skip_serializing_if = "Option::is_none")]
pub profile_tag: Option<String>,
/// The preferred language for receiving notifications (e.g. 'en' or 'en-US')
pub lang: String,
/// Information for the pusher implementation itself.
pub data: PusherData,
}