summaryrefslogtreecommitdiff
path: root/src/invite/routes/post.rs
blob: f7ca76c4b937630775e50c4a116a3429f72e07f2 (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.user, &issued_at).await?;
    Ok(Json(invite))
}

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