inital webhook support

This commit is contained in:
Zomatree
2022-11-26 23:07:22 +00:00
parent ee1c4cc2d5
commit 5cb2320760
31 changed files with 653 additions and 38 deletions

View 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))
}