add seperate non token webhook routes
This commit is contained in:
17
crates/delta/src/routes/webhooks/webhook_fetch_token.rs
Normal file
17
crates/delta/src/routes/webhooks/webhook_fetch_token.rs
Normal file
@@ -0,0 +1,17 @@
|
||||
use revolt_quark::{Db, Ref, Result, Error, models::Webhook};
|
||||
use rocket::serde::json::Json;
|
||||
|
||||
/// # gets a webhook
|
||||
///
|
||||
/// gets a webhook
|
||||
#[openapi(tag = "Webhooks")]
|
||||
#[get("/<target>/<token>")]
|
||||
pub async fn req(db: &Db, target: Ref, token: String) -> Result<Json<Webhook>> {
|
||||
let webhook = target.as_webhook(db).await?;
|
||||
|
||||
(webhook.token == token)
|
||||
.then_some(())
|
||||
.ok_or(Error::InvalidCredentials)?;
|
||||
|
||||
Ok(Json(webhook))
|
||||
}
|
||||
Reference in New Issue
Block a user