Compare commits

..

9 commits

Author SHA1 Message Date
3802ed126f FIXUP server-actor handler notify-users
All checks were successful
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
2024-07-23 19:26:32 +01:00
68cb9d6e41 FIXUP server-actor lib 2024-07-23 19:26:32 +01:00
d6245ed65e WIP: feat: post webhook to user 2024-07-23 19:25:51 +01:00
85ed7aeaa1 WIP: feat: dispatch NotifyUser messages to server actor (2/2) 2024-07-23 19:24:55 +01:00
67fc1b1b12 refactor: use Option<&T> over &Option<T> 2024-07-23 19:24:55 +01:00
f6456433b4 WIP: feat: dispatch NotifyUser messages to server actor (1/2) 2024-07-23 19:24:55 +01:00
357ad0d713 FIXUP server-actor handler receive valid server config 2024-07-23 19:24:53 +01:00
e29a2d29b6 WIP: feat: support sending messages to a notification webhook 2024-07-23 19:23:08 +01:00
f6bbdf7cce FIXUP config 2024-07-23 19:23:08 +01:00

View file

@ -1,5 +1,7 @@
use actix::prelude::*;
use git_next_config::server::NotificationType;
use git_next_webhook_actor::{AddWebhookRecipient, ShutdownWebhook, WebhookActor, WebhookRouter};
use standardwebhooks::Webhook;
use crate::{
messages::{ReceiveValidServerConfig, ValidServerConfig},
@ -19,6 +21,26 @@ impl Handler<ReceiveValidServerConfig> for ServerActor {
if let Some(webhook_actor_addr) = self.webhook_actor_addr.take() {
webhook_actor_addr.do_send(ShutdownWebhook);
}
match server_config.notification().r#type() {
NotificationType::None => { /* do nothing */ }
NotificationType::Webhook => {
// Create webhook signer
use secrecy::ExposeSecret;
let webhook = server_config
.notification()
.webhook_secret()
.map(|secret| Webhook::new(secret.expose_secret()))
.transpose()
.map_err(|e| {
tracing::error!(
"Invalid notification webhook secret (will not send notifications): {e}"
)
})
.ok()
.flatten();
self.webhook = webhook;
}
}
self.generation.inc();
// Webhook Server
tracing::info!("Starting Webhook Server...");