diff --git a/apps/desktop-shell/scripts/check-config.mjs b/apps/desktop-shell/scripts/check-config.mjs index 8fa76db41..575f89921 100644 --- a/apps/desktop-shell/scripts/check-config.mjs +++ b/apps/desktop-shell/scripts/check-config.mjs @@ -2563,6 +2563,7 @@ for (const snippet of [ 'DesktopNotificationPermissionAction', 'desktop_notification_permission_action', 'notification_permission_unavailable_response', + 'notification_delivery_unavailable_response', 'PermissionState::Granted', 'PermissionState::Denied', 'PermissionState::Prompt | PermissionState::PromptWithRationale', @@ -2570,9 +2571,11 @@ for (const snippet of [ 'json!({"action": HOST_BRIDGE_LOCAL_NOTIFICATION_DELIVERED_TO_SYSTEM_ACTION})', 'local_notification_payload_truncates_to_shared_contract_limits', 'notification_permission_unavailable_response_is_stable', + 'notification_delivery_unavailable_response_is_stable', '"a".repeat(HOST_BRIDGE_LOCAL_NOTIFICATION_TITLE_MAX_LENGTH)', '"b".repeat(HOST_BRIDGE_LOCAL_NOTIFICATION_BODY_MAX_LENGTH)', '"notification permission unavailable"', + '"notification delivery unavailable"', '"notification permission denied"', 'app.notification().builder()', ]) { diff --git a/apps/desktop-shell/src-tauri/src/host_bridge/notifications.rs b/apps/desktop-shell/src-tauri/src/host_bridge/notifications.rs index 7cd288738..a4abfb8b1 100644 --- a/apps/desktop-shell/src-tauri/src/host_bridge/notifications.rs +++ b/apps/desktop-shell/src-tauri/src/host_bridge/notifications.rs @@ -97,6 +97,14 @@ fn notification_permission_unavailable_response(request: &HostBridgeRequest) -> ) } +fn notification_delivery_unavailable_response(request: &HostBridgeRequest) -> HostBridgeResponse { + failed( + request.id.clone(), + "host_error", + "notification delivery unavailable", + ) +} + pub(crate) fn show_desktop_local_notification( app: &tauri::AppHandle, request: &HostBridgeRequest, @@ -142,7 +150,7 @@ pub(crate) fn show_desktop_local_notification( request.id.clone(), desktop_notification_delivered_to_system_result(), ), - Err(error) => failed(request.id.clone(), "host_error", error.to_string()), + Err(_) => notification_delivery_unavailable_response(request), } } @@ -200,6 +208,17 @@ mod tests { assert_eq!(error.message, "notification permission unavailable"); } + #[test] + fn notification_delivery_unavailable_response_is_stable() { + let request = request("notification.showLocal"); + + let response = notification_delivery_unavailable_response(&request); + let error = response.error.expect("error"); + + assert_eq!(error.code, "host_error"); + assert_eq!(error.message, "notification delivery unavailable"); + } + #[test] fn local_notification_payload_rejects_empty_and_control_text() { let mut empty = request("notification.showLocal");