Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

seanaye/chore/ios sound and logging (#1365)

Sean Aye954be782098b
diff --git a/rust/cloud-storage/notification/src/domain/models/apple.rs b/rust/cloud-storage/notification/src/domain/models/apple.rs
index b90de95824..02280363ad 100644
--- a/rust/cloud-storage/notification/src/domain/models/apple.rs
+++ b/rust/cloud-storage/notification/src/domain/models/apple.rs
@@ -3,7 +3,7 @@
use serde::{Deserialize, Serialize};
/// The APNS payload container.
-#[derive(Serialize, Debug, Default, Deserialize)]
+#[derive(Serialize, Debug, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub struct Aps {
/// The alert content.
@@ -43,6 +43,23 @@ pub struct Aps {
pub interruption_level: Option<InterruptionLevel>,
}
+impl Default for Aps {
+ fn default() -> Self {
+ Self {
+ alert: Default::default(),
+ badge: Default::default(),
+ // default to sending the default ios sound (which also controls vibration)
+ sound: Some(Sound::Default("default".to_string())),
+ content_available: Default::default(),
+ mutable_content: Default::default(),
+ category: Default::default(),
+ thread_id: Default::default(),
+ relevance_score: Default::default(),
+ interruption_level: Default::default(),
+ }
+ }
+}
+
/// The alert content of an APNS notification.
#[derive(Serialize, Debug, Deserialize)]
#[serde(untagged)]
diff --git a/rust/cloud-storage/notification/src/domain/ports.rs b/rust/cloud-storage/notification/src/domain/ports.rs
index 2918d0d333..99f22d2648 100644
--- a/rust/cloud-storage/notification/src/domain/ports.rs
+++ b/rust/cloud-storage/notification/src/domain/ports.rs
@@ -168,7 +168,8 @@ pub trait WebSocketSender: Send + Sync + 'static {
fn send_notifications<'a, T: Serialize + Send + Sync>(
&self,
message_type: &str,
- notifications: Vec<(MacroUserIdStr<'a>, &T)>,
+ recipients: &[MacroUserIdStr<'a>],
+ notification: &T,
) -> impl Future<Output = Result<HashSet<MacroUserIdStr<'static>>, Report>> + Send;
}
diff --git a/rust/cloud-storage/notification/src/domain/service/egress.rs b/rust/cloud-storage/notification/src/domain/service/egress.rs
index cbfae10f6a..d627682978 100644
--- a/rust/cloud-storage/notification/src/domain/service/egress.rs
+++ b/rust/cloud-storage/notification/src/domain/service/egress.rs
@@ -119,14 +119,8 @@ where
message_type: &str,
conn: &ConnGatewayNotification<'static, serde_json::Value>,
) -> Result<DeliverySuccess, Report> {
- let notifications: Vec<_> = conn
- .recipients
- .iter()
- .map(|r| (r.clone(), &conn.notif))
- .collect();
-
self.websocket
- .send_notifications(message_type, notifications)
+ .send_notifications(message_type, &conn.recipients, &conn.notif)
.await?;
Ok(DeliverySuccess::ConnGateway)
}
diff --git a/rust/cloud-storage/notification/src/domain/service/ingress.rs b/rust/cloud-storage/notification/src/domain/service/ingress.rs
index bab5957cb6..a96281be37 100644
--- a/rust/cloud-storage/notification/src/domain/service/ingress.rs
+++ b/rust/cloud-storage/notification/src/domain/service/ingress.rs
@@ -164,6 +164,7 @@ where
notif: APNSPushNotification {
aps: Aps {
content_available: Some(1),
+ sound: None,
..Default::default()
},
push_notification_data: ClearPushIdentifier {
diff --git a/rust/cloud-storage/notification/src/domain/service/test.rs b/rust/cloud-storage/notification/src/domain/service/test.rs
index f948f6c05f..9bb4d19a41 100644
--- a/rust/cloud-storage/notification/src/domain/service/test.rs
+++ b/rust/cloud-storage/notification/src/domain/service/test.rs
@@ -834,7 +834,8 @@ impl WebSocketSender for MockWebSocketSender {
async fn send_notifications<'a, T: Serialize + Send + Sync>(
&self,
_message_type: &str,
- _notifications: Vec<(MacroUserIdStr<'a>, &T)>,
+ _recipients: &[MacroUserIdStr<'a>],
+ _notification: &T,
) -> Result<HashSet<MacroUserIdStr<'static>>, Report> {
Ok(HashSet::new())
}
diff --git a/rust/cloud-storage/notification/src/outbound/websocket.rs b/rust/cloud-storage/notification/src/outbound/websocket.rs
index f1ffe8ce03..ddbd4f49e4 100644
--- a/rust/cloud-storage/notification/src/outbound/websocket.rs
+++ b/rust/cloud-storage/notification/src/outbound/websocket.rs
@@ -93,6 +93,7 @@ struct BatchSendMessageBody<'a> {
}
impl WebSocketGatewayOps for ConnectionGatewayClient {
+ #[tracing::instrument(err, skip(self, payload))]
async fn send_to_users<'a, T: Serialize + Send + Sync>(
&self,
message_type: &str,
@@ -122,7 +123,8 @@ impl WebSocketGatewayOps for ConnectionGatewayClient {
))
.json(&body)
.send()
- .await?;
+ .await?
+ .error_for_status()?;
let json = res.json().await?;
let response: GatewayResponse = serde_json::from_value(json)?;
@@ -149,17 +151,11 @@ impl<W: WebSocketGatewayOps + Send + Sync + 'static> WebSocketSender
async fn send_notifications<'a, T: Serialize + Send + Sync>(
&self,
message_type: &str,
- notifications: Vec<(MacroUserIdStr<'a>, &T)>,
+ recipients: &[MacroUserIdStr<'a>],
+ notification: &T,
) -> Result<HashSet<MacroUserIdStr<'static>>, Report> {
- // Get the first notification to serialize, return empty if none
- let Some((_, notification)) = notifications.first() else {
- return Ok(HashSet::new());
- };
-
- let user_ids: Vec<_> = notifications.iter().map(|(id, _)| id.clone()).collect();
-
self.gateway
- .send_to_users(message_type, &user_ids, *notification)
+ .send_to_users(message_type, recipients, notification)
.await
}
}