Files
stoatchat/crates/delta/src/routes/webhooks/webhook_fetch_token.rs
2025-11-18 14:57:34 +00:00

29 lines
703 B
Rust

use revolt_database::{util::reference::Reference, Database};
use revolt_models::v0::Webhook;
use revolt_result::Result;
use rocket::{serde::json::Json, State};
/// Gets a webhook
///
/// Gets a webhook with a token
#[utoipa::path(
tag = "Webhooks",
params(
("webhook_id" = Reference, Path),
("token" = String, Path),
),
responses(
(status = 200, body = Webhook),
),
)]
#[get("/<webhook_id>/<token>")]
pub async fn webhook_fetch_token(
db: &State<Database>,
webhook_id: Reference<'_>,
token: String,
) -> Result<Json<Webhook>> {
let webhook = webhook_id.as_webhook(db).await?;
webhook.assert_token(&token)?;
Ok(Json(webhook.into()))
}