diff --git a/veno-core/src/notifier/console.rs b/veno-core/src/notifier/console.rs new file mode 100644 index 0000000..a543570 --- /dev/null +++ b/veno-core/src/notifier/console.rs @@ -0,0 +1,13 @@ +use serde::Deserialize; +use serde_json::json; + +use super::SinkSender; + +#[derive(Debug, Clone, Deserialize)] +pub struct ConsoleSink {} + +impl SinkSender for ConsoleSink { + async fn send(&self, message: &str) { + println!("{message}") + } +} diff --git a/veno-core/src/notifier/mod.rs b/veno-core/src/notifier/mod.rs index 98a81db..0700154 100644 --- a/veno-core/src/notifier/mod.rs +++ b/veno-core/src/notifier/mod.rs @@ -1,8 +1,10 @@ +pub mod console; pub mod email; pub mod google_chat; pub mod slack; pub mod webhook; +use console::ConsoleSink; use email::EmailSink; use google_chat::GoogleChatSink; use serde::Deserialize; @@ -29,6 +31,8 @@ pub enum Sink { GoogleChat(GoogleChatSink), #[serde(rename = "webhook")] Webhook(WebhookSink), + #[serde(rename = "console")] + Console(ConsoleSink), } // TODO this could be either fire and forget and log errors or get a result and make a response but then use a join_all @@ -39,6 +43,7 @@ impl Sink { Sink::Email(sink) => sink.send(notification).await, Sink::GoogleChat(sink) => sink.send(notification).await, Sink::Webhook(sink) => sink.send(notification).await, + Sink::Console(sink) => sink.send(notification).await, } } } diff --git a/veno-web/src/api/notifiers/model.rs b/veno-web/src/api/notifiers/model.rs index ddf3087..ff7379a 100644 --- a/veno-web/src/api/notifiers/model.rs +++ b/veno-web/src/api/notifiers/model.rs @@ -20,6 +20,8 @@ pub enum SinkDto { GoogleChat(GoogleChatSink), #[serde(rename = "webhook")] Webhook(WebhookSink), + #[serde(rename = "console")] + Console(ConsoleSink), } #[derive(Debug, Clone, Serialize, ToSchema)] @@ -46,6 +48,9 @@ pub struct WebhookSink { pub webhook: String, } +#[derive(Debug, Clone, Serialize, ToSchema)] +pub struct ConsoleSink {} + impl From for NotifierResponse { fn from(value: Notifier) -> Self { Self { @@ -75,6 +80,7 @@ impl From for SinkDto { Sink::Webhook(webhook) => SinkDto::Webhook(WebhookSink { webhook: webhook.webhook, }), + Sink::Console(_) => SinkDto::Console(ConsoleSink {}), } } }