summaryrefslogtreecommitdiff
path: root/src/push/handlers/ping/mod.rs
blob: db828fa86bcf4d0f963ef0e0540bbeaf3f2fee0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use axum::{Json, extract::State, http::StatusCode};
use web_push::WebPushClient;

use crate::{error::Internal, push::app::Push, token::extract::Identity};

#[cfg(test)]
mod test;

#[derive(serde::Deserialize)]
pub struct Request {}

pub async fn handler<P>(
    State(push): State<Push<P>>,
    identity: Identity,
    Json(_): Json<Request>,
) -> Result<StatusCode, Internal>
where
    P: WebPushClient,
{
    push.ping(&identity.login).await?;

    Ok(StatusCode::ACCEPTED)
}