ralph/contracts/config/
notification.rs1use schemars::JsonSchema;
10use serde::{Deserialize, Serialize};
11
12#[derive(Debug, Clone, Serialize, Deserialize, Default, JsonSchema)]
14#[serde(default, deny_unknown_fields)]
15pub struct NotificationConfig {
16 pub enabled: Option<bool>,
19
20 pub notify_on_complete: Option<bool>,
22
23 pub notify_on_fail: Option<bool>,
25
26 pub notify_on_loop_complete: Option<bool>,
28
29 pub notify_on_watch_new_tasks: Option<bool>,
31
32 pub suppress_when_active: Option<bool>,
34
35 pub sound_enabled: Option<bool>,
37
38 pub sound_path: Option<String>,
41
42 #[schemars(range(min = 1000, max = 60000))]
44 pub timeout_ms: Option<u32>,
45}
46
47impl NotificationConfig {
48 pub fn merge_from(&mut self, other: Self) {
49 if other.enabled.is_some() {
50 self.enabled = other.enabled;
51 }
52 if other.notify_on_complete.is_some() {
53 self.notify_on_complete = other.notify_on_complete;
54 }
55 if other.notify_on_fail.is_some() {
56 self.notify_on_fail = other.notify_on_fail;
57 }
58 if other.notify_on_loop_complete.is_some() {
59 self.notify_on_loop_complete = other.notify_on_loop_complete;
60 }
61 if other.notify_on_watch_new_tasks.is_some() {
62 self.notify_on_watch_new_tasks = other.notify_on_watch_new_tasks;
63 }
64 if other.suppress_when_active.is_some() {
65 self.suppress_when_active = other.suppress_when_active;
66 }
67 if other.sound_enabled.is_some() {
68 self.sound_enabled = other.sound_enabled;
69 }
70 if other.sound_path.is_some() {
71 self.sound_path = other.sound_path;
72 }
73 if other.timeout_ms.is_some() {
74 self.timeout_ms = other.timeout_ms;
75 }
76 }
77}