add seperate non token webhook routes

This commit is contained in:
Zomatree
2023-01-27 17:26:32 +00:00
parent 758b1e43e7
commit 781d51df6f
7 changed files with 138 additions and 23 deletions

View File

@@ -0,0 +1,18 @@
use revolt_quark::{Db, Ref, Result, EmptyResponse, Error};
/// # Deletes a webhook with a token
///
/// deletes a webhook with a token
#[openapi(tag = "Webhooks")]
#[delete("/<target>/<token>")]
pub async fn req(db: &Db, target: Ref, token: String) -> Result<EmptyResponse> {
let webhook = target.as_webhook(db).await?;
(webhook.token == token)
.then_some(())
.ok_or(Error::InvalidCredentials)?;
webhook.delete(db).await?;
Ok(EmptyResponse)
}