mirror of
https://github.com/stoatchat/stoatchat.git
synced 2026-07-14 05:26:59 +00:00
make request function names the same as file name
This commit is contained in:
@@ -12,13 +12,13 @@ mod webhook_execute_github;
|
||||
|
||||
pub fn routes() -> (Vec<Route>, OpenApi) {
|
||||
openapi_get_routes_spec![
|
||||
webhook_delete_token::req,
|
||||
webhook_delete::req,
|
||||
webhook_edit_token::req,
|
||||
webhook_edit::req,
|
||||
webhook_execute::req,
|
||||
webhook_fetch_token::req,
|
||||
webhook_fetch::req,
|
||||
webhook_execute_github::req
|
||||
webhook_delete_token::webhook_delete_token,
|
||||
webhook_delete::webhook_delete,
|
||||
webhook_edit_token::webhook_edit_token,
|
||||
webhook_edit::webhook_edit,
|
||||
webhook_execute_github::webhook_execute_github,
|
||||
webhook_execute::webhook_execute,
|
||||
webhook_fetch_token::webhook_fetch_token,
|
||||
webhook_fetch::webhook_fetch,
|
||||
]
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use revolt_quark::{Db, Ref, Result, EmptyResponse, models::User, perms, Permissi
|
||||
/// deletes a webhook
|
||||
#[openapi(tag = "Webhooks")]
|
||||
#[delete("/<target>")]
|
||||
pub async fn req(db: &Db, user: User, target: Ref) -> Result<EmptyResponse> {
|
||||
pub async fn webhook_delete(db: &Db, user: User, target: Ref) -> Result<EmptyResponse> {
|
||||
let webhook = target.as_webhook(db).await?;
|
||||
|
||||
let channel = Ref::from_unchecked(webhook.channel.clone()).as_channel(db).await?;
|
||||
|
||||
@@ -5,7 +5,7 @@ use revolt_quark::{Db, Ref, Result, EmptyResponse, Error};
|
||||
/// deletes a webhook with a token
|
||||
#[openapi(tag = "Webhooks")]
|
||||
#[delete("/<target>/<token>")]
|
||||
pub async fn req(db: &Db, target: Ref, token: String) -> Result<EmptyResponse> {
|
||||
pub async fn webhook_delete_token(db: &Db, target: Ref, token: String) -> Result<EmptyResponse> {
|
||||
let webhook = target.as_webhook(db).await?;
|
||||
|
||||
(webhook.token.as_deref() == Some(&token))
|
||||
|
||||
@@ -20,7 +20,7 @@ pub struct WebhookEditBody {
|
||||
/// edits a webhook
|
||||
#[openapi(tag = "Webhooks")]
|
||||
#[patch("/<target>", data="<data>")]
|
||||
pub async fn req(db: &Db, target: Ref, user: User, data: Json<WebhookEditBody>) -> Result<Json<Webhook>> {
|
||||
pub async fn webhook_edit(db: &Db, target: Ref, user: User, data: Json<WebhookEditBody>) -> Result<Json<Webhook>> {
|
||||
let data = data.into_inner();
|
||||
data.validate()
|
||||
.map_err(|error| Error::FailedValidation { error })?;
|
||||
|
||||
@@ -20,7 +20,7 @@ pub struct WebhookEditBody {
|
||||
/// edits a webhook with a token
|
||||
#[openapi(tag = "Webhooks")]
|
||||
#[patch("/<target>/<token>", data="<data>")]
|
||||
pub async fn req(db: &Db, target: Ref, token: String, data: Json<WebhookEditBody>) -> Result<Json<Webhook>> {
|
||||
pub async fn webhook_edit_token(db: &Db, target: Ref, token: String, data: Json<WebhookEditBody>) -> Result<Json<Webhook>> {
|
||||
let data = data.into_inner();
|
||||
data.validate()
|
||||
.map_err(|error| Error::FailedValidation { error })?;
|
||||
|
||||
@@ -8,7 +8,7 @@ use validator::Validate;
|
||||
/// executes a webhook and sends a message
|
||||
#[openapi(tag = "Webhooks")]
|
||||
#[post("/<target>/<token>", data="<data>")]
|
||||
pub async fn req(db: &Db, target: Ref, token: String, data: Json<DataMessageSend>, idempotency: IdempotencyKey) -> Result<Json<Message>> {
|
||||
pub async fn webhook_execute(db: &Db, target: Ref, token: String, data: Json<DataMessageSend>, idempotency: IdempotencyKey) -> Result<Json<Message>> {
|
||||
let data = data.into_inner();
|
||||
data.validate()
|
||||
.map_err(|error| Error::FailedValidation { error })?;
|
||||
|
||||
@@ -742,7 +742,7 @@ fn convert_event(data: &str, event_name: &str) -> Result<Event> {
|
||||
/// executes a webhook specific to github and sends a message containg the relavent info about the event
|
||||
#[openapi(tag = "Webhooks")]
|
||||
#[post("/<target>/<token>/github", data="<data>")]
|
||||
pub async fn req(db: &Db, target: Ref, token: String, event: EventHeader<'_>, data: String) -> Result<()> {
|
||||
pub async fn webhook_execute_github(db: &Db, target: Ref, token: String, event: EventHeader<'_>, data: String) -> Result<()> {
|
||||
let webhook = target.as_webhook(db).await?;
|
||||
|
||||
(webhook.token.as_deref() == Some(&token))
|
||||
|
||||
@@ -21,7 +21,7 @@ pub struct WebhookData {
|
||||
/// gets a webhook
|
||||
#[openapi(tag = "Webhooks")]
|
||||
#[get("/<target>")]
|
||||
pub async fn req(db: &Db, target: Ref) -> Result<Json<WebhookData>> {
|
||||
pub async fn webhook_fetch(db: &Db, target: Ref) -> Result<Json<WebhookData>> {
|
||||
let Webhook { id, name, avatar, channel, .. } = target.as_webhook(db).await?;
|
||||
|
||||
Ok(Json(WebhookData { id, name, avatar, channel }))
|
||||
|
||||
@@ -6,7 +6,7 @@ use rocket::serde::json::Json;
|
||||
/// gets a webhook with a token
|
||||
#[openapi(tag = "Webhooks")]
|
||||
#[get("/<target>/<token>")]
|
||||
pub async fn req(db: &Db, target: Ref, token: String) -> Result<Json<Webhook>> {
|
||||
pub async fn webhook_fetch_token(db: &Db, target: Ref, token: String) -> Result<Json<Webhook>> {
|
||||
let webhook = target.as_webhook(db).await?;
|
||||
|
||||
(webhook.token.as_deref() == Some(&token))
|
||||
|
||||
Reference in New Issue
Block a user