Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions veno-core/src/notifier/console.rs
Original file line number Diff line number Diff line change
@@ -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}")
}
}
5 changes: 5 additions & 0 deletions veno-core/src/notifier/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
Expand 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,
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions veno-web/src/api/notifiers/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ pub enum SinkDto {
GoogleChat(GoogleChatSink),
#[serde(rename = "webhook")]
Webhook(WebhookSink),
#[serde(rename = "console")]
Console(ConsoleSink),
}

#[derive(Debug, Clone, Serialize, ToSchema)]
Expand All @@ -46,6 +48,9 @@ pub struct WebhookSink {
pub webhook: String,
}

#[derive(Debug, Clone, Serialize, ToSchema)]
pub struct ConsoleSink {}

impl From<Notifier> for NotifierResponse {
fn from(value: Notifier) -> Self {
Self {
Expand Down Expand Up @@ -75,6 +80,7 @@ impl From<Sink> for SinkDto {
Sink::Webhook(webhook) => SinkDto::Webhook(WebhookSink {
webhook: webhook.webhook,
}),
Sink::Console(_) => SinkDto::Console(ConsoleSink {}),
}
}
}
Loading