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
feat(notifications): return created_at/updated_at for created notification (#2478)
gbirman94ca6f3b5f19
diff --git a/rust/cloud-storage/notification/.sqlx/query-81f96534cd4a7b52d4ec2948dce8052076a25eea0af92eae1908e0e068af2116.json b/rust/cloud-storage/notification/.sqlx/query-81f96534cd4a7b52d4ec2948dce8052076a25eea0af92eae1908e0e068af2116.jsondeleted file mode 100644index 4cb16ae2df..0000000000--- a/rust/cloud-storage/notification/.sqlx/query-81f96534cd4a7b52d4ec2948dce8052076a25eea0af92eae1908e0e068af2116.json+++ /dev/null@@ -1,15 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n INSERT INTO user_notification (notification_id, user_id)\n SELECT $1, user_id\n FROM UNNEST($2::text[]) as user_id\n ",- "describe": {- "columns": [],- "parameters": {- "Left": [- "Uuid",- "TextArray"- ]- },- "nullable": []- },- "hash": "81f96534cd4a7b52d4ec2948dce8052076a25eea0af92eae1908e0e068af2116"-}diff --git a/rust/cloud-storage/notification/.sqlx/query-efc740cd935fb67ef5c2a75b3c37cf16bf09d6e52e5f6e5c5b107ef8244a141d.json b/rust/cloud-storage/notification/.sqlx/query-efc740cd935fb67ef5c2a75b3c37cf16bf09d6e52e5f6e5c5b107ef8244a141d.jsonnew file mode 100644index 0000000000..1cbb49a96b--- /dev/null+++ b/rust/cloud-storage/notification/.sqlx/query-efc740cd935fb67ef5c2a75b3c37cf16bf09d6e52e5f6e5c5b107ef8244a141d.json@@ -0,0 +1,23 @@+{+ "db_name": "PostgreSQL",+ "query": "\n INSERT INTO user_notification (notification_id, user_id)\n SELECT $1, user_id\n FROM UNNEST($2::text[]) as user_id\n RETURNING created_at::timestamptz as \"created_at!\"\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "created_at!",+ "type_info": "Timestamptz"+ }+ ],+ "parameters": {+ "Left": [+ "Uuid",+ "TextArray"+ ]+ },+ "nullable": [+ null+ ]+ },+ "hash": "efc740cd935fb67ef5c2a75b3c37cf16bf09d6e52e5f6e5c5b107ef8244a141d"+}diff --git a/rust/cloud-storage/notification/src/outbound/repository.rs b/rust/cloud-storage/notification/src/outbound/repository.rsindex bcd2920a67..fa3db914e6 100644--- a/rust/cloud-storage/notification/src/outbound/repository.rs+++ b/rust/cloud-storage/notification/src/outbound/repository.rs@@ -334,16 +334,17 @@ impl NotificationDbOps for PgPool {.map(|id| id.to_string()).collect();- sqlx::query!(+ let created_at = sqlx::query_scalar!(r#"INSERT INTO user_notification (notification_id, user_id)SELECT $1, user_idFROM UNNEST($2::text[]) as user_id+ RETURNING created_at::timestamptz as "created_at!""#,notification_id,&user_ids)- .execute(&mut *tx)+ .fetch_one(&mut *tx).await?;tx.commit().await?;@@ -363,9 +364,9 @@ impl NotificationDbOps for PgPool {entity: entity.clone(),sent: false,done: false,- created_at: None,+ created_at: Some(created_at),viewed_at: None,- updated_at: None,+ updated_at: Some(created_at),deleted_at: None,notification_metadata: n.clone(),sender_id: sender_id.clone(),diff --git a/rust/cloud-storage/notification/src/outbound/repository/test.rs b/rust/cloud-storage/notification/src/outbound/repository/test.rsindex a9182c2595..dd6b29224f 100644--- a/rust/cloud-storage/notification/src/outbound/repository/test.rs+++ b/rust/cloud-storage/notification/src/outbound/repository/test.rs@@ -153,6 +153,33 @@ async fn test_create_notification(pool: Pool<Postgres>) {assert_eq!(user_row.user_id, recipient.to_string());}+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]+async fn test_create_notification_returns_timestamps(pool: Pool<Postgres>) {+ let recipient = test_user("[email protected]");+ let notification_id = uuid::Uuid::new_v4();++ let request = SendNotificationRequestBuilder {+ notification_entity: EntityType::Document.with_entity_str("doc-1"),+ notification: TaggedContent::new(TestNotification {+ message: "hello".to_string(),+ }),+ sender_id: None,+ recipient_ids: std::collections::HashSet::from([recipient.clone()]),+ };++ let rows = pool+ .create_notification(request, notification_id, "test_service", None)+ .await+ .unwrap()+ .expect("should return Some for new notification");++ assert_eq!(rows.len(), 1);+ let row = &rows[0];+ assert!(row.created_at.is_some(), "created_at should be set");+ assert!(row.updated_at.is_some(), "updated_at should be set");+ assert_eq!(row.created_at, row.updated_at);+}+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS",fixtures(path = "../../../fixtures", scripts("user_notifications"))