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.

fix(notif): conn gateway timestamps (#2467)

Sean Ayec6b0b34f8696
diff --git a/rust/cloud-storage/notification/src/domain/models/queue_message.rs b/rust/cloud-storage/notification/src/domain/models/queue_message.rs
index 8f5eca75d8..59774a7a7d 100644
--- a/rust/cloud-storage/notification/src/domain/models/queue_message.rs
+++ b/rust/cloud-storage/notification/src/domain/models/queue_message.rs
@@ -225,6 +225,53 @@ pub(crate) enum NotificationChannel<'a, T, U> {
ConnGateway(ConnGatewayNotification<'a, T>),
}
+impl<'a, T, U> NotificationChannel<'a, T, U> {
+ fn with_timestamps(
+ self,
+ created_at: Option<DateTime<Utc>>,
+ updated_at: Option<DateTime<Utc>>,
+ ) -> Self {
+ match self {
+ NotificationChannel::Ios(apnstargets) => NotificationChannel::Ios(apnstargets),
+ NotificationChannel::Email(email_notification) => {
+ NotificationChannel::Email(email_notification)
+ }
+ NotificationChannel::ConnGateway(ConnGatewayNotification {
+ notif:
+ ConnGatewayInnerNotif {
+ notification_id,
+ notification_event_type,
+ entity,
+ sent,
+ done,
+ created_at: _,
+ viewed_at,
+ updated_at: _,
+ deleted_at,
+ notification_metadata,
+ sender_id,
+ },
+ recipients,
+ }) => NotificationChannel::ConnGateway(ConnGatewayNotification {
+ notif: ConnGatewayInnerNotif {
+ notification_id,
+ notification_event_type,
+ entity,
+ sent,
+ done,
+ created_at,
+ viewed_at,
+ updated_at,
+ deleted_at,
+ notification_metadata,
+ sender_id,
+ },
+ recipients,
+ }),
+ }
+ }
+}
+
/// Message published to SQS after DB persistence.
/// Contains everything needed for delivery.
///
@@ -260,6 +307,21 @@ impl<'a, T, U> QueueMessage<'a, T, U> {
content: NotificationChannel::Ios(Box::new(content)),
}
}
+
+ pub(crate) fn with_timestamps(
+ self,
+ created_at: Option<DateTime<Utc>>,
+ updated_at: Option<DateTime<Utc>>,
+ ) -> Self {
+ let QueueMessage {
+ message_type,
+ content,
+ } = self;
+ QueueMessage {
+ message_type,
+ content: content.with_timestamps(created_at, updated_at),
+ }
+ }
}
impl<'a, T, U> QueueMessage<'a, T, U> {
diff --git a/rust/cloud-storage/notification/src/domain/service/ingress.rs b/rust/cloud-storage/notification/src/domain/service/ingress.rs
index 63a37e6e50..440c70b070 100644
--- a/rust/cloud-storage/notification/src/domain/service/ingress.rs
+++ b/rust/cloud-storage/notification/src/domain/service/ingress.rs
@@ -232,6 +232,9 @@ where
}));
};
+ // get the timestamp info back out of the db created values
+ let timestamps = n.first().map(|n| (n.created_at, n.updated_at));
+
let results = join_all(
n.into_iter()
.map(|user_notif| self.state_machine_driver.ingest(user_notif)),
@@ -239,7 +242,17 @@ where
.await;
self.queue
- .publish(queue_messages.with_state_decisions(results).collect())
+ .publish(
+ queue_messages
+ .with_state_decisions(results)
+ .map(|msg| {
+ msg.with_timestamps(
+ timestamps.and_then(|v| v.0),
+ timestamps.and_then(|v| v.1),
+ )
+ })
+ .collect(),
+ )
.await
.context(SendNotificationError::Other)?;