diff --git a/crates/cli/src/server/actor/handlers/notify_user.rs b/crates/cli/src/server/actor/handlers/notify_user.rs index 85c5102e..cd5fb210 100644 --- a/crates/cli/src/server/actor/handlers/notify_user.rs +++ b/crates/cli/src/server/actor/handlers/notify_user.rs @@ -7,7 +7,7 @@ use tracing::Instrument; use crate::{repo::messages::NotifyUser, server::actor::ServerActor}; -use git_next_core::server::{self, Notification, NotificationType}; +use git_next_core::server::{self, OutboundWebhook}; impl Handler for ServerActor { type Result = (); @@ -19,9 +19,8 @@ impl Handler for ServerActor { let notification_config = server_config.notification().clone(); let net = self.net.clone(); async move { - match notification_config.r#type() { - NotificationType::None => { /* do nothing */ } - NotificationType::Webhook => send_webhook(msg, notification_config, net).await, + if let Some(webhook_config) = notification_config.webhook() { + send_webhook(msg, webhook_config, net).await; } } .in_current_span() @@ -32,13 +31,9 @@ impl Handler for ServerActor { async fn send_webhook( msg: NotifyUser, - notification_config: Notification, + webhook_config: &OutboundWebhook, net: kxio::network::Network, ) { - let Some(webhook_config) = notification_config.webhook() else { - tracing::warn!("Invalid notification configuration (config) - can't sent notification"); - return; - }; let Ok(webhook) = Webhook::from_bytes(webhook_config.secret().expose_secret().as_bytes().into()) else { diff --git a/crates/cli/src/server/server-default.toml b/crates/cli/src/server/server-default.toml index 6e086953..6cee97e0 100644 --- a/crates/cli/src/server/server-default.toml +++ b/crates/cli/src/server/server-default.toml @@ -6,8 +6,6 @@ port = 8080 url = "https://localhost:8080" # don't include any query path or a trailing slash [notification] # where updates from git-next should be sent to alert the user -type = "None" -# type = "Webhook" # webhook = { url = "https//localhost:9090", secret = "secret-password" } [storage] # where local copies of repositories will be cloned (bare) into diff --git a/crates/core/src/config/server.rs b/crates/core/src/config/server.rs index 3708d183..cd60b5d8 100644 --- a/crates/core/src/config/server.rs +++ b/crates/core/src/config/server.rs @@ -159,25 +159,6 @@ impl ServerStorage { } } -/// Identifier for the type of Notification -#[derive( - Clone, - Default, - Debug, - derive_more::From, - PartialEq, - Eq, - PartialOrd, - Ord, - serde::Deserialize, - Copy, -)] -pub enum NotificationType { - #[default] - None, - Webhook, -} - /// Defines the Webhook Forges should send updates to /// Must be an address that is accessible from the remote forge #[derive( @@ -192,27 +173,18 @@ pub enum NotificationType { serde::Deserialize, )] pub struct Notification { - r#type: NotificationType, webhook: Option, } impl Notification { pub const fn none() -> Self { - Self { - r#type: NotificationType::None, - webhook: None, - } + Self { webhook: None } } pub const fn new_webhook(webhook: OutboundWebhook) -> Self { Self { - r#type: NotificationType::Webhook, webhook: Some(webhook), } } - pub const fn r#type(&self) -> NotificationType { - self.r#type - } - pub const fn webhook(&self) -> Option<&OutboundWebhook> { self.webhook.as_ref() }