WIP: send out push notification, impl pusher routes
It seems in order to test this I may also have to impl the email 3pid route? I need to call the set_pusher route somehow.
This commit is contained in:
parent
a0ecd76e21
commit
2d69e81699
6 changed files with 514 additions and 166 deletions
|
@ -666,20 +666,36 @@ pub async fn delete_pushrule_route(
|
|||
Ok(delete_pushrule::Response.into())
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "conduit_bin", get("/_matrix/client/r0/pushers"))]
|
||||
pub async fn get_pushers_route() -> ConduitResult<get_pushers::Response> {
|
||||
#[cfg_attr(
|
||||
feature = "conduit_bin",
|
||||
get("/_matrix/client/r0/pushers", data = "<body>")
|
||||
)]
|
||||
pub async fn get_pushers_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<get_pushers::Request>,
|
||||
) -> ConduitResult<get_pushers::Response> {
|
||||
let sender = body.sender_user.as_ref().expect("authenticated endpoint");
|
||||
|
||||
Ok(get_pushers::Response {
|
||||
pushers: Vec::new(),
|
||||
pushers: db.pusher.get_pusher(sender)?,
|
||||
}
|
||||
.into())
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "conduit_bin", post("/_matrix/client/r0/pushers/set"))]
|
||||
pub async fn set_pushers_route(db: State<'_, Database>) -> ConduitResult<get_pushers::Response> {
|
||||
#[cfg_attr(
|
||||
feature = "conduit_bin",
|
||||
post("/_matrix/client/r0/pushers/set", data = "<body>")
|
||||
)]
|
||||
pub async fn set_pushers_route(
|
||||
db: State<'_, Database>,
|
||||
body: Ruma<set_pusher::Request>,
|
||||
) -> ConduitResult<set_pusher::Response> {
|
||||
let sender = body.sender_user.as_ref().expect("authenticated endpoint");
|
||||
let pusher = body.pusher.clone();
|
||||
|
||||
db.pusher.set_pusher(sender, pusher)?;
|
||||
|
||||
db.flush().await?;
|
||||
|
||||
Ok(get_pushers::Response {
|
||||
pushers: Vec::new(),
|
||||
}
|
||||
.into())
|
||||
Ok(set_pusher::Response::default().into())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue