From 312e1dd41f1c1d8e04d57aabda36d184219fdf52 Mon Sep 17 00:00:00 2001 From: Zomatree Date: Thu, 20 Apr 2023 17:45:48 +0100 Subject: [PATCH] update code to be inline with reviews --- crates/delta/src/routes/webhooks/webhook_delete.rs | 4 ++-- crates/delta/src/routes/webhooks/webhook_delete_token.rs | 2 +- crates/delta/src/routes/webhooks/webhook_edit_token.rs | 2 +- crates/delta/src/routes/webhooks/webhook_execute_github.rs | 2 +- crates/delta/src/routes/webhooks/webhook_fetch.rs | 2 +- crates/delta/src/routes/webhooks/webhook_fetch_token.rs | 4 ++-- crates/quark/src/impl/dummy/channels/webhook.rs | 2 +- crates/quark/src/impl/generic/channels/webhook.rs | 3 +-- crates/quark/src/impl/mongo/channels/webhook.rs | 2 +- crates/quark/src/models/channels/message.rs | 2 -- crates/quark/src/traits/channels/webhook.rs | 2 +- 11 files changed, 12 insertions(+), 15 deletions(-) diff --git a/crates/delta/src/routes/webhooks/webhook_delete.rs b/crates/delta/src/routes/webhooks/webhook_delete.rs index 2d3991c6..040f5de6 100644 --- a/crates/delta/src/routes/webhooks/webhook_delete.rs +++ b/crates/delta/src/routes/webhooks/webhook_delete.rs @@ -1,8 +1,8 @@ use revolt_quark::{Db, Ref, Result, EmptyResponse, models::User, perms, Permission}; -/// # Deletes a webhook with a token +/// # Deletes a webhook /// -/// deletes a webhook with a token +/// deletes a webhook #[openapi(tag = "Webhooks")] #[delete("/")] pub async fn req(db: &Db, user: User, target: Ref) -> Result { diff --git a/crates/delta/src/routes/webhooks/webhook_delete_token.rs b/crates/delta/src/routes/webhooks/webhook_delete_token.rs index 2161ac24..b0dea18d 100644 --- a/crates/delta/src/routes/webhooks/webhook_delete_token.rs +++ b/crates/delta/src/routes/webhooks/webhook_delete_token.rs @@ -1,6 +1,6 @@ use revolt_quark::{Db, Ref, Result, EmptyResponse, Error}; -/// # Deletes a webhook with a token +/// # Deletes a webhook /// /// deletes a webhook with a token #[openapi(tag = "Webhooks")] diff --git a/crates/delta/src/routes/webhooks/webhook_edit_token.rs b/crates/delta/src/routes/webhooks/webhook_edit_token.rs index f99ff3c9..a5256310 100644 --- a/crates/delta/src/routes/webhooks/webhook_edit_token.rs +++ b/crates/delta/src/routes/webhooks/webhook_edit_token.rs @@ -15,7 +15,7 @@ pub struct WebhookEditBody { remove: Vec } -/// # Edits a webhook with a token +/// # Edits a webhook /// /// edits a webhook with a token #[openapi(tag = "Webhooks")] diff --git a/crates/delta/src/routes/webhooks/webhook_execute_github.rs b/crates/delta/src/routes/webhooks/webhook_execute_github.rs index ecdf4eaf..e8538856 100644 --- a/crates/delta/src/routes/webhooks/webhook_execute_github.rs +++ b/crates/delta/src/routes/webhooks/webhook_execute_github.rs @@ -737,7 +737,7 @@ fn convert_event(data: &str, event_name: &str) -> Result { }) } -/// # executes a webhook specific to github +/// # Executes a webhook specific to github /// /// executes a webhook specific to github and sends a message containg the relavent info about the event #[openapi(tag = "Webhooks")] diff --git a/crates/delta/src/routes/webhooks/webhook_fetch.rs b/crates/delta/src/routes/webhooks/webhook_fetch.rs index d1b919f8..53d87989 100644 --- a/crates/delta/src/routes/webhooks/webhook_fetch.rs +++ b/crates/delta/src/routes/webhooks/webhook_fetch.rs @@ -16,7 +16,7 @@ pub struct WebhookData { pub channel: String, } -/// # gets a webhook +/// # Gets a webhook /// /// gets a webhook #[openapi(tag = "Webhooks")] diff --git a/crates/delta/src/routes/webhooks/webhook_fetch_token.rs b/crates/delta/src/routes/webhooks/webhook_fetch_token.rs index 4c346ffc..04ce4d62 100644 --- a/crates/delta/src/routes/webhooks/webhook_fetch_token.rs +++ b/crates/delta/src/routes/webhooks/webhook_fetch_token.rs @@ -1,9 +1,9 @@ use revolt_quark::{Db, Ref, Result, Error, models::Webhook}; use rocket::serde::json::Json; -/// # gets a webhook +/// # Gets a webhook /// -/// gets a webhook +/// gets a webhook with a token #[openapi(tag = "Webhooks")] #[get("//")] pub async fn req(db: &Db, target: Ref, token: String) -> Result> { diff --git a/crates/quark/src/impl/dummy/channels/webhook.rs b/crates/quark/src/impl/dummy/channels/webhook.rs index c22b579b..63917732 100644 --- a/crates/quark/src/impl/dummy/channels/webhook.rs +++ b/crates/quark/src/impl/dummy/channels/webhook.rs @@ -26,7 +26,7 @@ impl AbstractWebhook for DummyDb { }) } - async fn update_webook(&self, webhook_id: &str, partial_webhook: &PartialWebhook, remove: &[FieldsWebhook]) -> Result<()> { + async fn update_webhook(&self, webhook_id: &str, partial_webhook: &PartialWebhook, remove: &[FieldsWebhook]) -> Result<()> { info!("updating webhook {webhook_id}, {partial_webhook:?}, removing {remove:?}"); Ok(()) diff --git a/crates/quark/src/impl/generic/channels/webhook.rs b/crates/quark/src/impl/generic/channels/webhook.rs index 71c81015..c830c0ad 100644 --- a/crates/quark/src/impl/generic/channels/webhook.rs +++ b/crates/quark/src/impl/generic/channels/webhook.rs @@ -42,7 +42,7 @@ impl Webhook { self.apply_options(partial.clone()); - db.update_webook(&self.id, &partial, &remove).await?; + db.update_webhook(&self.id, &partial, &remove).await?; partial.token = None; // Avoid leaking the token to people who receive the event @@ -65,7 +65,6 @@ impl Webhook { pub fn into_message_webhook(self) -> MessageWebhook { MessageWebhook { - id: self.id, name: self.name, avatar: self.avatar.map(|f| f.id) } diff --git a/crates/quark/src/impl/mongo/channels/webhook.rs b/crates/quark/src/impl/mongo/channels/webhook.rs index f7f58fe9..b7657b3d 100644 --- a/crates/quark/src/impl/mongo/channels/webhook.rs +++ b/crates/quark/src/impl/mongo/channels/webhook.rs @@ -26,7 +26,7 @@ impl AbstractWebhook for MongoDb { Ok(()) } - async fn update_webook(&self, webhook_id: &str, partial_webhook: &PartialWebhook, remove: &[FieldsWebhook]) -> Result<()> { + async fn update_webhook(&self, webhook_id: &str, partial_webhook: &PartialWebhook, remove: &[FieldsWebhook]) -> Result<()> { self.update_one_by_id( COL, webhook_id, diff --git a/crates/quark/src/models/channels/message.rs b/crates/quark/src/models/channels/message.rs index 264868f2..c9c74f59 100644 --- a/crates/quark/src/models/channels/message.rs +++ b/crates/quark/src/models/channels/message.rs @@ -112,8 +112,6 @@ pub struct Interactions { /// Information about the webhook which #[derive(Serialize, Deserialize, JsonSchema, Debug, Clone, Validate, Default)] pub struct MessageWebhook { - // Id of Webhook - pub id: String, // The name of the webhook - 1 to 32 chars pub name: String, // The id of the avatar of the webhook, if it has one diff --git a/crates/quark/src/traits/channels/webhook.rs b/crates/quark/src/traits/channels/webhook.rs index 1836cf62..bee30c5b 100644 --- a/crates/quark/src/traits/channels/webhook.rs +++ b/crates/quark/src/traits/channels/webhook.rs @@ -6,6 +6,6 @@ pub trait AbstractWebhook: Sync + Send { async fn insert_webhook(&self, webhook: &Webhook) -> Result<()>; async fn fetch_webhook(&self, webhook_id: &str) -> Result; async fn delete_webhook(&self, webhook_id: &str) -> Result<()>; - async fn update_webook(&self, webhook_id: &str, partial_webhook: &PartialWebhook, remove: &[FieldsWebhook]) -> Result<()>; + async fn update_webhook(&self, webhook_id: &str, partial_webhook: &PartialWebhook, remove: &[FieldsWebhook]) -> Result<()>; async fn fetch_webhooks_for_channel(&self, channel: &str) -> Result>; }