Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
flag off clearing ios notifs (#6928)
Sean Aye9b9242822e0e
diff --git a/crates/notification/Cargo.toml b/crates/notification/Cargo.tomlindex e84536112b..7e0f171c40 100644--- a/crates/notification/Cargo.toml+++ b/crates/notification/Cargo.toml@@ -6,16 +6,23 @@ version = "0.1.0"[features]-ai_tool = ["dep:ai_toolset", "dep:anyhow", "dep:async-trait", "dep:schemars", "notification_state/schema"]+ai_tool = [+ "dep:ai_toolset",+ "dep:anyhow",+ "dep:async-trait",+ "dep:schemars",+ "notification_state/schema",+]axum = ["dep:axum","dep:macro_authorization","dep:model-error-response","dep:model_user",- "models_pagination/axum","dep:serde_with",+ "models_pagination/axum","schema",]+clear_ios_push = []docs = ["dep:aquamarine"]redis-tests = []schema = ["dep:utoipa", "macro_user_id/schema", "notification_state/schema"]@@ -39,12 +46,12 @@ hmac = { workspace = true }itertools = { workspace = true }kafka_util = { path = "../kafka_util" }last_online_tracker = { path = "../last_online_tracker" }-macro_event_broker = { path = "../macro_event_broker" }-macro_event_topics = { path = "../macro_event_topics" }macro_authorization = { path = "../macro_authorization", default-features = false, features = ["axum",], optional = true }macro_env = { path = "../macro_env" }+macro_event_broker = { path = "../macro_event_broker" }+macro_event_topics = { path = "../macro_event_topics" }macro_service_urls = { path = "../macro_service_urls" }macro_user_id = { path = "../macro_user_id" }macro_uuid = { path = "../macro_uuid" }@@ -54,12 +61,12 @@ model_user = { path = "../model_user", optional = true }models_pagination = { path = "../models_pagination" }notification_state = { path = "../notification_state", features = ["postgres"] }rate_limit = { path = "../rate_limit" }+rdkafka = { workspace = true }redis = { workspace = true, features = ["aio","tokio-comp","tokio-rustls-comp",] }-rdkafka = { workspace = true }reqwest = { workspace = true }rootcause = { workspace = true }schemars = { workspace = true, optional = true }diff --git a/crates/notification/src/domain/models/request.rs b/crates/notification/src/domain/models/request.rsindex 45e6de3a3d..faf10a5b21 100644--- a/crates/notification/src/domain/models/request.rs+++ b/crates/notification/src/domain/models/request.rs@@ -276,13 +276,17 @@ impl NotificationStatus {/// returns true if we should be clearing the relevant push notifications/// for this notificationpub(crate) fn should_clear_push_notifs(&self) -> bool {- use super::NotificationAction;- let action = match self {- NotificationStatus::Seen => NotificationAction::MarkSeen,- NotificationStatus::Done(true) => NotificationAction::MarkDone,- NotificationStatus::Done(false) => NotificationAction::Reopen,- };- action.should_clear_push_notifications()+ if cfg!(feature = "clear_ios_push") {+ use super::NotificationAction;+ let action = match self {+ NotificationStatus::Seen => NotificationAction::MarkSeen,+ NotificationStatus::Done(true) => NotificationAction::MarkDone,+ NotificationStatus::Done(false) => NotificationAction::Reopen,+ };+ action.should_clear_push_notifications()+ } else {+ false+ }}}diff --git a/crates/notification/src/domain/service/test.rs b/crates/notification/src/domain/service/test.rsindex d18a346bc8..7731f78817 100644--- a/crates/notification/src/domain/service/test.rs+++ b/crates/notification/src/domain/service/test.rs@@ -1664,7 +1664,7 @@ async fn test_get_entity_notifications_batch_deserializes_tagged_metadata() {// ============================================================================#[tokio::test]-async fn test_mark_seen_publishes_ios_clear_message() {+async fn test_mark_seen_clears_push_only_when_enabled() {use std::sync::Arc;let user = test_user_id("[email protected]");@@ -1704,8 +1704,16 @@ async fn test_mark_seen_publishes_ios_clear_message() {assert_eq!(mark_seen_calls.len(), 1);assert_eq!(mark_seen_calls[0].1, vec![notif_id]);- // Verify queue message was publishedlet published = queue.get_published();+ if !cfg!(feature = "clear_ios_push") {+ assert!(+ published.is_empty(),+ "Should not clear push when clear_ios_push is disabled"+ );+ return;+ }++ // Verify queue message was publishedassert_eq!(published.len(), 1);let msg = &published[0];@@ -2016,7 +2024,7 @@ async fn test_mark_seen_skips_push_when_no_device_endpoints() {}#[tokio::test]-async fn test_mark_done_updates_db_and_clears_push() {+async fn test_mark_done_updates_db_and_clears_push_only_when_enabled() {use std::sync::Arc;let user = test_user_id("[email protected]");@@ -2060,10 +2068,16 @@ async fn test_mark_done_updates_db_and_clears_push() {assert_eq!(mark_done_calls[0].1, vec![notif_id]);assert!(mark_done_calls[0].2, "Should mark as done=true");- // Verify push clearing was published (Done(true) should clear push)let published = queue.get_published();- assert_eq!(published.len(), 1);- assert_eq!(published[0]["message_type"], "clear_push_notification");+ if cfg!(feature = "clear_ios_push") {+ assert_eq!(published.len(), 1);+ assert_eq!(published[0]["message_type"], "clear_push_notification");+ } else {+ assert!(+ published.is_empty(),+ "Should not clear push when clear_ios_push is disabled"+ );+ }}#[tokio::test]