Compare commits

..

7 commits

Author SHA1 Message Date
3e196558ef WIP
All checks were successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
2024-07-22 07:52:51 +01:00
94b618c962 WIP: feat: post webhook to user 2024-07-22 07:51:54 +01:00
16b8bc40dd WIP: feat: dispatch NotifyUser messages to server actor (2/2) 2024-07-22 07:18:27 +01:00
acc4725124 refactor: use Option<&T> over &Option<T> 2024-07-22 07:18:24 +01:00
eb3dbe4696 WIP: feat: dispatch NotifyUser messages to server actor (1/2) 2024-07-22 07:17:03 +01:00
7d77ef8a84 WIP: feat: support sending messages to a notification webhook 2024-07-22 07:16:34 +01:00
3c0b7096e2 WIP: feat: configure a webhook for receiving notifications 2024-07-22 07:16:29 +01:00

View file

@ -1,5 +1,4 @@
// //
use actix::prelude::*; use actix::prelude::*;
use git_next_config::server::NotificationType; use git_next_config::server::NotificationType;
use git_next_repo_actor::messages::NotifyUser; use git_next_repo_actor::messages::NotifyUser;
@ -13,8 +12,8 @@ impl Handler<NotifyUser> for ServerActor {
let Some(server_config) = &self.server_config else { let Some(server_config) = &self.server_config else {
return; return;
}; };
let notification_type = server_config.notification().r#type(); let notification = &server_config.notification();
match notification_type { match notification.r#type() {
NotificationType::None => { /* do nothing */ } NotificationType::None => { /* do nothing */ }
NotificationType::Webhook => { NotificationType::Webhook => {
let message_id = format!("msg_{}", ulid::Ulid::new()); let message_id = format!("msg_{}", ulid::Ulid::new());
@ -23,7 +22,7 @@ impl Handler<NotifyUser> for ServerActor {
let timestamp = timestamp.unix_timestamp(); let timestamp = timestamp.unix_timestamp();
let to_sign = format!("{message_id}.{timestamp}.{payload}"); let to_sign = format!("{message_id}.{timestamp}.{payload}");
tracing::info!(?to_sign, ""); tracing::info!(?to_sign, "");
let Some(webhook) = self.webhook.as_ref() else { let Some(webhook) = notification.webhook.as_ref() else {
tracing::warn!("Invalid notification configuration - can't sent notification"); tracing::warn!("Invalid notification configuration - can't sent notification");
return; return;
}; };