summaryrefslogtreecommitdiff
path: root/src/invite/routes/post.rs
blob: 898081e3ea78172ab022b884d0c51305d43b1eae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use axum::extract::{Json, State};

use crate::{
    app::App, clock::RequestedAt, error::Internal, invite::Invite, token::extract::Identity,
};

pub async fn handler(
    State(app): State<App>,
    RequestedAt(issued_at): RequestedAt,
    identity: Identity,
    _: Json<Request>,
) -> Result<Json<Invite>, Internal> {
    let invite = app.invites().issue(&identity.login, &issued_at).await?;
    Ok(Json(invite))
}

// Require `{}` as the only valid request for this endpoint.
#[derive(Default, serde::Deserialize)]
pub struct Request {}