| @@ -51,6 +51,7 @@ pub async fn register_notifications( |
| 51 | } |
51 | } |
| 52 | let notify_via = settings.tunables.notifications.via; |
52 | let notify_via = settings.tunables.notifications.via; |
| 53 | let show_message = settings.tunables.notifications.show_message; |
53 | let show_message = settings.tunables.notifications.show_message; |
| |
54 | let sound_hint = settings.tunables.notifications.sound_hint.clone(); |
| 54 | let server_settings = client.notification_settings().await; |
55 | let server_settings = client.notification_settings().await; |
| 55 | let Some(startup_ts) = MilliSecondsSinceUnixEpoch::from_system_time(SystemTime::now()) else { |
56 | let Some(startup_ts) = MilliSecondsSinceUnixEpoch::from_system_time(SystemTime::now()) else { |
| 56 | return; |
57 | return; |
| @@ -61,6 +62,7 @@ pub async fn register_notifications( |
| 61 | .register_notification_handler(move |notification, room: MatrixRoom, client: Client| { |
62 | .register_notification_handler(move |notification, room: MatrixRoom, client: Client| { |
| 62 | let store = store.clone(); |
63 | let store = store.clone(); |
| 63 | let server_settings = server_settings.clone(); |
64 | let server_settings = server_settings.clone(); |
| |
65 | let sound_hint = sound_hint.clone(); |
| 64 | async move { |
66 | async move { |
| 65 | let mode = global_or_room_mode(&server_settings, &room).await; |
67 | let mode = global_or_room_mode(&server_settings, &room).await; |
| 66 | if mode == RoomNotificationMode::Mute { |
68 | if mode == RoomNotificationMode::Mute { |
| @@ -90,6 +92,7 @@ pub async fn register_notifications( |
| 90 | body.as_deref(), |
92 | body.as_deref(), |
| 91 | room_id, |
93 | room_id, |
| 92 | &store, |
94 | &store, |
| |
95 | sound_hint.as_deref(), |
| 93 | ) |
96 | ) |
| 94 | .await; |
97 | .await; |
| 95 | }, |
98 | }, |
| @@ -114,10 +117,11 @@ async fn send_notification( |
| 114 | body: Option<&str>, |
117 | body: Option<&str>, |
| 115 | room_id: OwnedRoomId, |
118 | room_id: OwnedRoomId, |
| 116 | store: &AsyncProgramStore, |
119 | store: &AsyncProgramStore, |
| |
120 | sound_hint: Option<&str>, |
| 117 | ) { |
121 | ) { |
| 118 | #[cfg(feature = "desktop")] |
122 | #[cfg(feature = "desktop")] |
| 119 | if via.desktop { |
123 | if via.desktop { |
| 120 | send_notification_desktop(summary, body, room_id, store).await; |
124 | send_notification_desktop(summary, body, room_id, store, sound_hint).await; |
| 121 | } |
125 | } |
| 122 | #[cfg(not(feature = "desktop"))] |
126 | #[cfg(not(feature = "desktop"))] |
| 123 | { |
127 | { |
| @@ -140,6 +144,7 @@ async fn send_notification_desktop( |
| 140 | body: Option<&str>, |
144 | body: Option<&str>, |
| 141 | room_id: OwnedRoomId, |
145 | room_id: OwnedRoomId, |
| 142 | _store: &AsyncProgramStore, |
146 | _store: &AsyncProgramStore, |
| |
147 | sound_hint: Option<&str>, |
| 143 | ) { |
148 | ) { |
| 144 | let mut desktop_notification = notify_rust::Notification::new(); |
149 | let mut desktop_notification = notify_rust::Notification::new(); |
| 145 | desktop_notification |
150 | desktop_notification |
| @@ -148,6 +153,10 @@ async fn send_notification_desktop( |
| 148 | .icon(IAMB_XDG_NAME) |
153 | .icon(IAMB_XDG_NAME) |
| 149 | .action("default", "default"); |
154 | .action("default", "default"); |
| 150 | |
155 | |
| |
156 | if let Some(sound_hint) = sound_hint { |
| |
157 | desktop_notification.sound_name(sound_hint); |
| |
158 | } |
| |
159 | |
| 151 | #[cfg(all(unix, not(target_os = "macos")))] |
160 | #[cfg(all(unix, not(target_os = "macos")))] |
| 152 | desktop_notification.urgency(notify_rust::Urgency::Normal); |
161 | desktop_notification.urgency(notify_rust::Urgency::Normal); |
| 153 | |
162 | |