use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize, Default, JsonSchema)]
#[serde(default, deny_unknown_fields)]
pub struct NotificationConfig {
pub enabled: Option<bool>,
pub notify_on_complete: Option<bool>,
pub notify_on_fail: Option<bool>,
pub notify_on_loop_complete: Option<bool>,
pub notify_on_watch_new_tasks: Option<bool>,
pub suppress_when_active: Option<bool>,
pub sound_enabled: Option<bool>,
pub sound_path: Option<String>,
#[schemars(range(min = 1000, max = 60000))]
pub timeout_ms: Option<u32>,
}
impl NotificationConfig {
pub fn merge_from(&mut self, other: Self) {
if other.enabled.is_some() {
self.enabled = other.enabled;
}
if other.notify_on_complete.is_some() {
self.notify_on_complete = other.notify_on_complete;
}
if other.notify_on_fail.is_some() {
self.notify_on_fail = other.notify_on_fail;
}
if other.notify_on_loop_complete.is_some() {
self.notify_on_loop_complete = other.notify_on_loop_complete;
}
if other.notify_on_watch_new_tasks.is_some() {
self.notify_on_watch_new_tasks = other.notify_on_watch_new_tasks;
}
if other.suppress_when_active.is_some() {
self.suppress_when_active = other.suppress_when_active;
}
if other.sound_enabled.is_some() {
self.sound_enabled = other.sound_enabled;
}
if other.sound_path.is_some() {
self.sound_path = other.sound_path;
}
if other.timeout_ms.is_some() {
self.timeout_ms = other.timeout_ms;
}
}
}