Compare commits

..

5 commits

Author SHA1 Message Date
e3a36d4c24 WIP
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-22 08:54:58 +01:00
7365b619fe WIP: feat: post webhook to user 2024-07-22 08:54:19 +01:00
08d302ec65 WIP: feat: dispatch NotifyUser messages to server actor (2/2) 2024-07-22 08:51:50 +01:00
7b4fd52264 refactor: use Option<&T> over &Option<T> 2024-07-22 08:51:48 +01:00
1e169856e9 WIP: feat: dispatch NotifyUser messages to server actor (1/2) 2024-07-22 08:51:44 +01:00
3 changed files with 7 additions and 3 deletions

View file

@ -199,7 +199,7 @@ impl Notification {
webhook: None,
}
}
pub const fn webhook(webhook: OutboundWebhook) -> Self {
pub const fn new_webhook(webhook: OutboundWebhook) -> Self {
Self {
r#type: NotificationType::Webhook,
webhook: Some(webhook),
@ -210,6 +210,10 @@ impl Notification {
self.r#type
}
pub const fn webhook(&self) -> Option<&OutboundWebhook> {
self.webhook.as_ref()
}
pub fn webhook_url(&self) -> Option<String> {
self.webhook.clone().map(|x| x.url)
}

View file

@ -751,7 +751,7 @@ mod given {
ServerStorage::new(a_name().into())
}
pub fn a_notification_config() -> Notification {
Notification::webhook(an_outbound_webhook())
Notification::new_webhook(an_outbound_webhook())
}
pub fn some_forge_configs() -> BTreeMap<String, ForgeConfig> {
[(a_name(), a_forge_config())].into()

View file

@ -22,7 +22,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) = notification.webhook() else {
tracing::warn!("Invalid notification configuration - can't sent notification");
return;
};