Compare commits

..

7 commits

Author SHA1 Message Date
31859a0c69 WIP: post webhook - apply some to previous commits
All checks were successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
ci/woodpecker/push/cron-docker-builder Pipeline was successful
2024-07-21 20:22:42 +01:00
731c22826c WIP: feat: post webhook to user 2024-07-21 19:43:56 +01:00
8b2deba6de WIP: feat: dispatch NotifyUser messages to server actor (2/2) 2024-07-21 13:45:04 +01:00
d8f256bedc refactor: use Option<&T> over &Option<T> 2024-07-21 13:29:05 +01:00
e5f2bac00c WIP: feat: dispatch NotifyUser messages to server actor (1/2) 2024-07-21 13:28:51 +01:00
022e6bcbb0 WIP: feat: support sending messages to a notification webhook
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-19 07:59:57 +01:00
f50cb40cf0 WIP: feat: configure a webhook for receiving notifications 2024-07-19 07:59:57 +01:00

View file

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