Compare commits

..

5 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
3 changed files with 3 additions and 7 deletions

View file

@ -199,7 +199,7 @@ impl Notification {
webhook: None,
}
}
pub const fn new_webhook(webhook: OutboundWebhook) -> Self {
pub const fn webhook(webhook: OutboundWebhook) -> Self {
Self {
r#type: NotificationType::Webhook,
webhook: Some(webhook),
@ -210,10 +210,6 @@ 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::new_webhook(an_outbound_webhook())
Notification::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() else {
let Some(webhook) = notification.webhook.as_ref() else {
tracing::warn!("Invalid notification configuration - can't sent notification");
return;
};