1//! `POST /_matrix/client/*/pushers/set`
2//!
3//! This endpoint allows the creation, modification and deletion of pushers for this user ID.
45mod set_pusher_serde;
67pub mod v3 {
8//! `/v3/` ([spec])
9 //!
10 //! [spec]: https://spec.matrix.org/latest/client-server-api/#post_matrixclientv3pushersset
1112use ruma_common::{
13 api::{request, response, Metadata},
14 metadata,
15 };
16use serde::Serialize;
1718use crate::push::{Pusher, PusherIds};
1920const METADATA: Metadata = metadata! {
21 method: POST,
22 rate_limited: true,
23 authentication: AccessToken,
24 history: {
251.0 => "/_matrix/client/r0/pushers/set",
261.1 => "/_matrix/client/v3/pushers/set",
27 }
28 };
2930/// Request type for the `set_pusher` endpoint.
31#[request(error = crate::Error)]
32pub struct Request {
33/// The action to take.
34#[ruma_api(body)]
35pub action: PusherAction,
36 }
3738/// Response type for the `set_pusher` endpoint.
39#[response(error = crate::Error)]
40 #[derive(Default)]
41pub struct Response {}
4243impl Request {
44/// Creates a new `Request` for the given action.
45pub fn new(action: PusherAction) -> Self {
46Self { action }
47 }
4849/// Creates a new `Request` to create or update the given pusher.
50pub fn post(pusher: Pusher) -> Self {
51Self::new(PusherAction::Post(PusherPostData { pusher, append: false }))
52 }
5354/// Creates a new `Request` to delete the pusher identified by the given IDs.
55pub fn delete(ids: PusherIds) -> Self {
56Self::new(PusherAction::Delete(ids))
57 }
58 }
5960impl Response {
61/// Creates an empty `Response`.
62pub fn new() -> Self {
63Self {}
64 }
65 }
6667/// The action to take for the pusher.
68#[derive(Clone, Debug)]
69 #[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
70pub enum PusherAction {
71/// Create or update the given pusher.
72Post(PusherPostData),
7374/// Delete the pusher identified by the given IDs.
75Delete(PusherIds),
76 }
7778/// Data necessary to create or update a pusher.
79#[derive(Clone, Debug, Serialize)]
80 #[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
81pub struct PusherPostData {
82/// The pusher to configure.
83#[serde(flatten)]
84pub pusher: Pusher,
8586/// Controls if another pusher with the same pushkey and app id should be created, if there
87 /// are already others for other users.
88 ///
89 /// Defaults to `false`. See the spec for more details.
90#[serde(skip_serializing_if = "ruma_common::serde::is_default")]
91pub append: bool,
92 }
93}