fix: shout.desktop should be optional
Some checks failed
Rust / build (push) Successful in 2m34s
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
Release Please / Release-plz (push) Failing after 15s

If the value isn't present, then it is treated as false
This commit is contained in:
Paul Campbell 2024-08-04 16:02:06 +01:00
parent a9783807b3
commit 3895246b72
3 changed files with 11 additions and 5 deletions

View file

@ -26,10 +26,12 @@ impl Handler<NotifyUser> for AlertsActor {
if let Some(email_config) = shout.email() {
send_email(&user_notification, email_config);
}
if shout.desktop() {
if let Some(desktop) = shout.desktop() {
if desktop {
send_desktop_notification(&user_notification);
}
}
}
.in_current_span()
.into_actor(self)
.wait(ctx);

View file

@ -209,7 +209,7 @@ impl ServerStorage {
pub struct Shout {
webhook: Option<OutboundWebhook>,
email: Option<EmailConfig>,
desktop: bool,
desktop: Option<bool>,
}
impl Shout {
pub const fn webhook(&self) -> Option<&OutboundWebhook> {
@ -228,7 +228,7 @@ impl Shout {
self.email.as_ref()
}
pub const fn desktop(&self) -> bool {
pub const fn desktop(&self) -> Option<bool> {
self.desktop
}
}

View file

@ -774,7 +774,11 @@ mod given {
ServerStorage::new(a_name().into())
}
pub fn a_shout() -> Shout {
Shout::new(Some(an_outbound_webhook()), Some(an_email_config()), true)
Shout::new(
Some(an_outbound_webhook()),
Some(an_email_config()),
Some(true),
)
}
pub fn some_forge_configs() -> BTreeMap<String, ForgeConfig> {
[(a_name(), a_forge_config())].into()