mirror of
https://github.com/stoatchat/stoatchat.git
synced 2026-07-14 13:36:59 +00:00
29 lines
703 B
Rust
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()))
|
|
}
|