diff --git a/migrations/20240417170201_notification_metadata.sql b/migrations/20240417170201_notification_metadata.sql new file mode 100644 index 00000000..4f34f07f --- /dev/null +++ b/migrations/20240417170201_notification_metadata.sql @@ -0,0 +1,2 @@ +ALTER TABLE notification ADD COLUMN data VARCHAR(255) NULL DEFAULT NULL; +ALTER TABLE welcome_notification ADD COLUMN data VARCHAR(255) NULL DEFAULT NULL; diff --git a/src/model/helpers.rs b/src/model/helpers.rs index f2d5d2a0..c06875ea 100644 --- a/src/model/helpers.rs +++ b/src/model/helpers.rs @@ -874,6 +874,7 @@ pub struct Notification { pub body: String, pub icon: Option, pub url: Option, + pub data: Option, pub is_read: bool, } @@ -970,6 +971,7 @@ pub async fn get_notifications_for_subscriber( notification.title, notification.body, notification.url, + notification.data, notification.icon FROM notification JOIN subscriber_notification ON subscriber_notification.notification=notification.id @@ -1046,6 +1048,8 @@ pub struct WelcomeNotification { pub body: String, #[validate(length(min = 1, max = 255))] pub url: Option, + #[validate(length(min = 1, max = 255))] + pub data: Option, } #[instrument(skip(postgres, metrics))] @@ -1055,7 +1059,7 @@ pub async fn get_welcome_notification( metrics: Option<&Metrics>, ) -> Result, sqlx::Error> { let query = " - SELECT enabled, type, title, body, url + SELECT enabled, type, title, body, url, data FROM welcome_notification WHERE project=$1 "; @@ -1078,14 +1082,15 @@ pub async fn set_welcome_notification( metrics: Option<&Metrics>, ) -> Result<(), sqlx::Error> { let query = " - INSERT INTO welcome_notification (project, enabled, type, title, body, url) - VALUES ($1, $2, $3, $4, $5, $6) + INSERT INTO welcome_notification (project, enabled, type, title, body, url, data) + VALUES ($1, $2, $3, $4, $5, $6, $7) ON CONFLICT (project) DO UPDATE SET enabled=EXCLUDED.enabled, type=EXCLUDED.type, title=EXCLUDED.title, body=EXCLUDED.body, - url=EXCLUDED.url + url=EXCLUDED.url, + data=EXCLUDED.data "; let start = Instant::now(); sqlx::query(query) @@ -1095,6 +1100,7 @@ pub async fn set_welcome_notification( .bind(welcome_notification.title) .bind(welcome_notification.body) .bind(welcome_notification.url) + .bind(welcome_notification.data) .execute(postgres) .await?; if let Some(metrics) = metrics { diff --git a/src/notify_message.rs b/src/notify_message.rs index b58c4015..b57290dc 100644 --- a/src/notify_message.rs +++ b/src/notify_message.rs @@ -63,5 +63,6 @@ pub struct JwtNotification { pub body: String, pub icon: String, pub url: String, + pub data: Option, pub is_read: bool, } diff --git a/src/services/public_http_server/handlers/relay_webhook/handlers/notify_subscribe.rs b/src/services/public_http_server/handlers/relay_webhook/handlers/notify_subscribe.rs index f1e5e06d..a5f2b6d1 100644 --- a/src/services/public_http_server/handlers/relay_webhook/handlers/notify_subscribe.rs +++ b/src/services/public_http_server/handlers/relay_webhook/handlers/notify_subscribe.rs @@ -218,6 +218,7 @@ pub async fn handle(msg: RelayIncomingMessage, state: &AppState) -> Result<(), R title: welcome_notification.title, body: welcome_notification.body, url: welcome_notification.url, + data: welcome_notification.data, icon: None, }, &state.postgres, diff --git a/src/services/publisher_service/helpers.rs b/src/services/publisher_service/helpers.rs index 762b6521..af12ba6b 100644 --- a/src/services/publisher_service/helpers.rs +++ b/src/services/publisher_service/helpers.rs @@ -31,13 +31,14 @@ pub async fn upsert_notification( pub body: String, pub icon: Option, pub url: Option, + pub data: Option, } let query = " - INSERT INTO notification (project, notification_id, type, title, body, icon, url) - VALUES ($1, $2, $3, $4, $5, $6, $7) + INSERT INTO notification (project, notification_id, type, title, body, icon, url, data) + VALUES ($1, $2, $3, $4, $5, $6, $7, $8) ON CONFLICT (project, notification_id) DO UPDATE SET notification_id=EXCLUDED.notification_id - RETURNING id, type, title, body, icon, url + RETURNING id, type, title, body, icon, url, data "; let start = Instant::now(); let result = sqlx::query_as::(query) @@ -48,6 +49,7 @@ pub async fn upsert_notification( .bind(notification.body) .bind(notification.icon) .bind(notification.url) + .bind(notification.data) .fetch_one(postgres) .await?; if let Some(metrics) = metrics { @@ -61,6 +63,7 @@ pub async fn upsert_notification( body: result.body, icon: result.icon, url: result.url, + data: result.data, }, }) } @@ -98,6 +101,7 @@ pub struct NotificationToProcess { pub notification_body: String, pub notification_icon: Option, pub notification_url: Option, + pub notification_data: Option, pub subscriber: Uuid, #[sqlx(try_from = "String")] pub subscriber_account: AccountId, @@ -159,6 +163,7 @@ pub async fn pick_subscriber_notification_for_processing( notification.body AS notification_body, notification.icon AS notification_icon, notification.url AS notification_url, + notification.data AS notification_data, subscriber.id AS subscriber, subscriber.account AS subscriber_account, subscriber.sym_key AS subscriber_sym_key, diff --git a/src/services/publisher_service/mod.rs b/src/services/publisher_service/mod.rs index 88889316..fe197409 100644 --- a/src/services/publisher_service/mod.rs +++ b/src/services/publisher_service/mod.rs @@ -326,6 +326,7 @@ async fn process_notification( .to_string() }) .unwrap_or_default(), + data: notification.notification_data.clone(), is_read: notification.subscriber_notification_is_read, }), notification.subscriber_account.clone(), diff --git a/src/types/notification.rs b/src/types/notification.rs index 079ef298..d35fb2f0 100644 --- a/src/types/notification.rs +++ b/src/types/notification.rs @@ -16,6 +16,8 @@ pub struct Notification { pub icon: Option, #[validate(length(min = 1, max = 255))] pub url: Option, + #[validate(length(min = 1, max = 255))] + pub data: Option, } impl Notification { @@ -37,6 +39,7 @@ mod test { body: "body".to_owned(), icon: None, url: None, + data: None, } .validate() .is_ok()); @@ -47,6 +50,7 @@ mod test { body: "body".to_owned(), icon: Some("icon".to_owned()), url: Some("url".to_owned()), + data: None, } .validate() .is_ok()); @@ -60,6 +64,7 @@ mod test { body: "body".to_owned(), icon: None, url: None, + data: None, } .validate() .is_err()); @@ -70,6 +75,7 @@ mod test { body: "".to_owned(), icon: Some("icon".to_owned()), url: Some("url".to_owned()), + data: None, } .validate() .is_err()); @@ -80,6 +86,7 @@ mod test { body: "body".to_owned(), icon: Some("".to_owned()), url: Some("url".to_owned()), + data: None, } .validate() .is_err()); @@ -90,6 +97,7 @@ mod test { body: "body".to_owned(), icon: Some("icon".to_owned()), url: Some("".to_owned()), + data: None, } .validate() .is_err()); diff --git a/tests/deployment.rs b/tests/deployment.rs index 110b6b57..8c4ff328 100644 --- a/tests/deployment.rs +++ b/tests/deployment.rs @@ -218,6 +218,7 @@ async fn deployment_integration() { body: "body".to_owned(), icon: None, url: None, + data: None, }; let notify_body = NotifyBody { @@ -257,6 +258,7 @@ async fn deployment_integration() { assert_eq!(claims.msg.body, "body"); assert_eq!(claims.msg.icon, ""); assert_eq!(claims.msg.url, ""); + assert_eq!(claims.msg.data, None); unregister_identity_key( identity_key_details.keys_server_url, diff --git a/tests/integration.rs b/tests/integration.rs index 614478cb..db688d19 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -1343,6 +1343,7 @@ async fn test_notify_v0(notify_server: &NotifyServerContext) { body: "body".to_owned(), icon: None, url: None, + data: None, }; let notify_body = NotifyBody { @@ -1383,6 +1384,7 @@ async fn test_notify_v0(notify_server: &NotifyServerContext) { assert_eq!(claims.msg.body, "body"); assert_eq!(claims.msg.icon, ""); assert_eq!(claims.msg.url, ""); + assert_eq!(claims.msg.data, None); } #[test_context(NotifyServerContext)] @@ -1441,6 +1443,7 @@ async fn test_notify_v1(notify_server: &NotifyServerContext) { body: "body".to_owned(), icon: Some("icon".to_owned()), url: Some("url".to_owned()), + data: Some("data".to_owned()), }; let notification_body = NotifyBodyNotification { @@ -1488,6 +1491,7 @@ async fn test_notify_v1(notify_server: &NotifyServerContext) { assert_eq!(claims.msg.body, notification.body); assert_eq!(Some(&claims.msg.icon), notification.icon.as_ref()); assert_ne!(claims.msg.url, ""); + assert_eq!(claims.msg.data, Some("data".to_owned())); } #[test_context(NotifyServerContext)] @@ -1587,6 +1591,7 @@ async fn test_notify_v0_only_required_fields(notify_server: &NotifyServerContext assert_eq!(claims.msg.body, "body"); assert_eq!(claims.msg.icon, ""); assert_eq!(claims.msg.url, ""); + assert_eq!(claims.msg.data, None); } #[test_context(NotifyServerContext)] @@ -1618,6 +1623,7 @@ async fn test_notify_v1_response_not_found(notify_server: &NotifyServerContext) body: "body".to_owned(), icon: Some("icon".to_owned()), url: Some("url".to_owned()), + data: None, }; let notification_body = NotifyBodyNotification { @@ -1696,6 +1702,7 @@ async fn test_notify_v1_response_not_subscribed_to_scope(notify_server: &NotifyS body: "body".to_owned(), icon: Some("icon".to_owned()), url: Some("url".to_owned()), + data: None, }; let notification_body = NotifyBodyNotification { @@ -1782,6 +1789,7 @@ async fn test_notify_idempotent(notify_server: &NotifyServerContext) { body: "body".to_owned(), icon: Some("icon".to_owned()), url: Some("url".to_owned()), + data: Some("data".to_owned()), }, accounts: vec![account.clone()], }]; @@ -1940,6 +1948,7 @@ async fn test_notify_rate_limit(notify_server: &NotifyServerContext) { body: "body".to_owned(), icon: None, url: None, + data: None, }, accounts: vec![], }]; @@ -2029,6 +2038,7 @@ async fn test_notify_subscriber_rate_limit(notify_server: &NotifyServerContext) body: "body".to_owned(), icon: None, url: None, + data: None, }, accounts: vec![account.clone()], }]; @@ -2159,6 +2169,7 @@ async fn test_notify_subscriber_rate_limit_single(notify_server: &NotifyServerCo body: "body".to_owned(), icon: None, url: None, + data: None, }, accounts: vec![account1.clone(), account2.clone()], }]; @@ -2324,6 +2335,7 @@ async fn test_notify_non_existant_project(notify_server: &NotifyServerContext) { body: "body".to_owned(), icon: Some("icon".to_owned()), url: Some("url".to_owned()), + data: None, }; let notification_body = NotifyBodyNotification { @@ -2553,6 +2565,7 @@ async fn test_dead_letter_and_giveup_checks() { body: "body".to_owned(), icon: None, url: None, + data: None, }, &postgres, None, @@ -3550,6 +3563,7 @@ async fn delete_subscription(notify_server: &NotifyServerContext) { body: "body".to_owned(), icon: Some("icon".to_owned()), url: Some("url".to_owned()), + data: None, }; let notify_body = NotifyBody { @@ -3590,6 +3604,7 @@ async fn delete_subscription(notify_server: &NotifyServerContext) { assert_eq!(claims.msg.body, notification.body); assert_eq!(claims.msg.icon, "icon"); assert_ne!(claims.msg.url, ""); + assert_eq!(claims.msg.data, None); let mut relay_client2 = relay_client.clone(); delete( @@ -4559,6 +4574,7 @@ async fn e2e_get_notifications_has_one(notify_server: &NotifyServerContext) { body: "body".to_owned(), icon: None, url: None, + data: None, }; let notify_body = NotifyBody { @@ -4714,6 +4730,7 @@ async fn get_notifications_1() { body: "body".to_owned(), icon: None, url: None, + data: None, }; let notification_with_id = upsert_notification( @@ -4801,6 +4818,7 @@ async fn get_notifications_4() { body: "body".to_owned(), icon: None, url: None, + data: None, }; let notification_with_id = upsert_notification( @@ -4904,6 +4922,7 @@ async fn get_notifications_5() { body: "body".to_owned(), icon: None, url: None, + data: None, }; let notification_with_id = upsert_notification( @@ -5006,6 +5025,7 @@ async fn get_notifications_6() { body: "body".to_owned(), icon: None, url: None, + data: None, }; let notification_with_id = upsert_notification( @@ -5134,6 +5154,7 @@ async fn get_notifications_7() { body: "body".to_owned(), icon: None, url: None, + data: None, }; let notification_with_id = upsert_notification( @@ -5246,6 +5267,7 @@ async fn different_created_at() { body: "body".to_owned(), icon: None, url: None, + data: None, }; let notification_with_id = upsert_notification( @@ -5360,6 +5382,7 @@ async fn duplicate_created_at() { body: "body".to_owned(), icon: None, url: None, + data: None, }; let notification_with_id = upsert_notification( @@ -5501,6 +5524,7 @@ async fn set_a_welcome_notification() { title: "title".to_owned(), body: "body".to_owned(), url: None, + data: None, }; set_welcome_notification(project.id, welcome_notification.clone(), &postgres, None) @@ -5516,6 +5540,7 @@ async fn set_a_welcome_notification() { assert_eq!(welcome_notification.title, got_notification.title); assert_eq!(welcome_notification.body, got_notification.body); assert_eq!(welcome_notification.url, got_notification.url); + assert_eq!(welcome_notification.data, got_notification.data); } #[tokio::test] @@ -5568,6 +5593,7 @@ async fn set_a_welcome_notification_for_different_project() { title: "title".to_owned(), body: "body".to_owned(), url: None, + data: None, }; set_welcome_notification(project1.id, welcome_notification, &postgres, None) @@ -5611,6 +5637,7 @@ async fn update_welcome_notification() { title: "title".to_owned(), body: "body".to_owned(), url: None, + data: None, }; set_welcome_notification(project.id, welcome_notification.clone(), &postgres, None) .await @@ -5624,6 +5651,7 @@ async fn update_welcome_notification() { assert_eq!(welcome_notification.title, got_notification.title); assert_eq!(welcome_notification.body, got_notification.body); assert_eq!(welcome_notification.url, got_notification.url); + assert_eq!(welcome_notification.data, got_notification.data); } { @@ -5633,6 +5661,7 @@ async fn update_welcome_notification() { title: "title2".to_owned(), body: "body2".to_owned(), url: Some("url".to_owned()), + data: Some("data".to_owned()), }; set_welcome_notification(project.id, welcome_notification.clone(), &postgres, None) .await @@ -5646,6 +5675,7 @@ async fn update_welcome_notification() { assert_eq!(welcome_notification.title, got_notification.title); assert_eq!(welcome_notification.body, got_notification.body); assert_eq!(welcome_notification.url, got_notification.url); + assert_eq!(welcome_notification.data, got_notification.data); } } @@ -5718,6 +5748,7 @@ async fn http_get_a_welcome_notification(notify_server: &NotifyServerContext) { title: "title".to_owned(), body: "body".to_owned(), url: None, + data: None, }; set_welcome_notification( @@ -5783,6 +5814,7 @@ async fn http_set_a_welcome_notification(notify_server: &NotifyServerContext) { title: "title".to_owned(), body: "body".to_owned(), url: None, + data: None, }; assert_successful_response( @@ -5810,6 +5842,7 @@ async fn http_set_a_welcome_notification(notify_server: &NotifyServerContext) { assert_eq!(welcome_notification.title, got_notification.title); assert_eq!(welcome_notification.body, got_notification.body); assert_eq!(welcome_notification.url, got_notification.url); + assert_eq!(welcome_notification.data, got_notification.data); } #[test_context(NotifyServerContext)] @@ -5827,6 +5860,7 @@ async fn e2e_set_a_welcome_notification(notify_server: &NotifyServerContext) { title: "title".to_owned(), body: "body".to_owned(), url: None, + data: None, }; assert_successful_response( @@ -5868,6 +5902,7 @@ async fn e2e_set_a_welcome_notification(notify_server: &NotifyServerContext) { assert_eq!(welcome_notification.title, got_notification.title); assert_eq!(welcome_notification.body, got_notification.body); assert_eq!(welcome_notification.url, got_notification.url); + assert_eq!(welcome_notification.data, got_notification.data); } #[test_context(NotifyServerContext)] @@ -5893,6 +5928,7 @@ async fn e2e_send_welcome_notification(notify_server: &NotifyServerContext) { title: "title".to_owned(), body: "body".to_owned(), url: Some("url".to_owned()), + data: Some("data".to_owned()), }; assert_successful_response( @@ -5999,6 +6035,7 @@ async fn e2e_send_single_welcome_notification(notify_server: &NotifyServerContex title: "title".to_owned(), body: "body".to_owned(), url: None, + data: None, }, ¬ify_server.postgres, None, @@ -6161,6 +6198,7 @@ async fn e2e_doesnt_send_welcome_notification(notify_server: &NotifyServerContex title: "title".to_owned(), body: "body".to_owned(), url: Some("url".to_owned()), + data: Some("data".to_owned()), }; assert_successful_response( @@ -6321,6 +6359,7 @@ async fn delete_and_resubscribe(notify_server: &NotifyServerContext) { body: "body".to_owned(), icon: Some("icon".to_owned()), url: Some("url".to_owned()), + data: Some("data".to_owned()), }; let notify_body = NotifyBody { @@ -6361,6 +6400,7 @@ async fn delete_and_resubscribe(notify_server: &NotifyServerContext) { assert_eq!(claims.msg.body, notification.body); assert_eq!(claims.msg.icon, "icon"); assert_ne!(claims.msg.url, ""); + assert_eq!(claims.msg.data, notification.data); let mut relay_client2 = relay_client.clone(); delete( @@ -6443,6 +6483,7 @@ async fn delete_and_resubscribe(notify_server: &NotifyServerContext) { body: "body".to_owned(), icon: Some("icon".to_owned()), url: Some("url".to_owned()), + data: Some("data".to_owned()), }; let notify_body = NotifyBody { @@ -6483,6 +6524,7 @@ async fn delete_and_resubscribe(notify_server: &NotifyServerContext) { assert_eq!(claims.msg.body, notification.body); assert_eq!(claims.msg.icon, "icon"); assert_ne!(claims.msg.url, ""); + assert_eq!(claims.msg.data, notification.data); } #[test_context(NotifyServerContext)] @@ -8012,6 +8054,7 @@ async fn same_address_different_chain_notify(notify_server: &NotifyServerContext body: "body".to_owned(), icon: None, url: None, + data: None, }; let (_, address2) = generate_account(); @@ -8059,6 +8102,7 @@ async fn same_address_different_chain_notify(notify_server: &NotifyServerContext assert_eq!(claims.msg.body, "body"); assert_eq!(claims.msg.icon, ""); assert_eq!(claims.msg.url, ""); + assert_eq!(claims.msg.data, None); } #[test_context(NotifyServerContext)] @@ -8867,23 +8911,28 @@ async fn account_most_messages_kept() { .await .unwrap(); - let notification_with_id = upsert_notification( - Uuid::new_v4().to_string(), - project.id, - Notification { - r#type: Uuid::new_v4(), - title: "title".to_owned(), - body: "body".to_owned(), - icon: None, - url: None, - }, - &postgres, - None, - ) - .await - .unwrap(); + #[derive(Debug, FromRow)] + pub struct Result { + pub id: Uuid, + } + let query = " + INSERT INTO notification (project, notification_id, type, title, body, icon, url) + VALUES ($1, $2, $3, $4, $5, $6, $7) + RETURNING id + "; + let Result { id } = sqlx::query_as::(query) + .bind(project.id) + .bind(Uuid::new_v4().to_string()) + .bind(Uuid::new_v4()) + .bind("title".to_owned()) + .bind("body".to_owned()) + .bind(None::) + .bind(None::) + .fetch_one(&postgres) + .await + .unwrap(); - upsert_subscriber_notifications(notification_with_id.id, &[subscriber2.id], &postgres, None) + upsert_subscriber_notifications(id, &[subscriber2.id], &postgres, None) .await .unwrap(); @@ -8950,44 +8999,50 @@ async fn account_most_messages_kept2() { .await .unwrap(); - let notification_with_id = upsert_notification( - Uuid::new_v4().to_string(), - project.id, - Notification { - r#type: Uuid::new_v4(), - title: "title".to_owned(), - body: "body".to_owned(), - icon: None, - url: None, - }, - &postgres, - None, - ) - .await - .unwrap(); - upsert_subscriber_notifications(notification_with_id.id, &[subscriber1.id], &postgres, None) + #[derive(Debug, FromRow)] + pub struct Result { + pub id: Uuid, + } + let query = " + INSERT INTO notification (project, notification_id, type, title, body, icon, url) + VALUES ($1, $2, $3, $4, $5, $6, $7) + RETURNING id + "; + let Result { id } = sqlx::query_as::(query) + .bind(project.id) + .bind(Uuid::new_v4().to_string()) + .bind(Uuid::new_v4()) + .bind("title".to_owned()) + .bind("body".to_owned()) + .bind(None::) + .bind(None::) + .fetch_one(&postgres) .await .unwrap(); - upsert_subscriber_notifications(notification_with_id.id, &[subscriber2.id], &postgres, None) + upsert_subscriber_notifications(id, &[subscriber1.id], &postgres, None) + .await + .unwrap(); + upsert_subscriber_notifications(id, &[subscriber2.id], &postgres, None) .await .unwrap(); - let notification_with_id = upsert_notification( - Uuid::new_v4().to_string(), - project.id, - Notification { - r#type: Uuid::new_v4(), - title: "title".to_owned(), - body: "body".to_owned(), - icon: None, - url: None, - }, - &postgres, - None, - ) - .await - .unwrap(); - upsert_subscriber_notifications(notification_with_id.id, &[subscriber2.id], &postgres, None) + let query = " + INSERT INTO notification (project, notification_id, type, title, body, icon, url) + VALUES ($1, $2, $3, $4, $5, $6, $7) + RETURNING id + "; + let Result { id } = sqlx::query_as::(query) + .bind(project.id) + .bind(Uuid::new_v4().to_string()) + .bind(Uuid::new_v4()) + .bind("title".to_owned()) + .bind("body".to_owned()) + .bind(None::) + .bind(None::) + .fetch_one(&postgres) + .await + .unwrap(); + upsert_subscriber_notifications(id, &[subscriber2.id], &postgres, None) .await .unwrap(); @@ -9051,23 +9106,28 @@ async fn run_test_duplicate_address_migration( } for (project_id, account) in notifications { - let notification_with_id = upsert_notification( - Uuid::new_v4().to_string(), - inserted_projects[&project_id].id, - Notification { - r#type: Uuid::new_v4(), - title: "title".to_owned(), - body: "body".to_owned(), - icon: None, - url: None, - }, - &postgres, - None, - ) - .await - .unwrap(); + #[derive(Debug, FromRow)] + pub struct Result { + pub id: Uuid, + } + let query = " + INSERT INTO notification (project, notification_id, type, title, body, icon, url) + VALUES ($1, $2, $3, $4, $5, $6, $7) + RETURNING id + "; + let Result { id } = sqlx::query_as::(query) + .bind(inserted_projects[&project_id].id) + .bind(Uuid::new_v4().to_string()) + .bind(Uuid::new_v4()) + .bind("title".to_owned()) + .bind("body".to_owned()) + .bind(None::) + .bind(None::) + .fetch_one(&postgres) + .await + .unwrap(); upsert_subscriber_notifications( - notification_with_id.id, + id, &[inserted_subscribers[&(&project_id, &account)].id], &postgres, None, @@ -9963,6 +10023,7 @@ async fn notification_link(notify_server: &NotifyServerContext) { body: "body".to_owned(), icon: None, url: Some(test_url.to_owned()), + data: None, }; let notify_body = NotifyBody { @@ -10026,6 +10087,7 @@ async fn notification_link(notify_server: &NotifyServerContext) { assert_eq!(notification.title, gotten_notification.title); assert_eq!(notification.body, gotten_notification.body); assert_ne!(notification.url, gotten_notification.url); + assert_eq!(notification.data, gotten_notification.data); assert_eq!(gotten_notification.url.as_ref(), Some(&claims.msg.url)); @@ -10111,6 +10173,7 @@ async fn notification_link_no_link(notify_server: &NotifyServerContext) { body: "body".to_owned(), icon: None, url: None, + data: None, }; let notify_body = NotifyBody { @@ -10150,6 +10213,7 @@ async fn notification_link_no_link(notify_server: &NotifyServerContext) { assert_eq!(notification.title, claims.msg.title); assert_eq!(notification.body, claims.msg.body); assert_eq!("", claims.msg.url); + assert_eq!(notification.data, claims.msg.data); let result = get_notifications( &mut relay_client, @@ -10174,6 +10238,7 @@ async fn notification_link_no_link(notify_server: &NotifyServerContext) { assert_eq!(notification.title, gotten_notification.title); assert_eq!(notification.body, gotten_notification.body); assert_eq!(notification.url, None); + assert_eq!(notification.data, gotten_notification.data); assert_eq!(claims.msg.id, gotten_notification.id); @@ -10301,6 +10366,7 @@ async fn notification_link_multiple_subscribers_different_links( body: "body".to_owned(), icon: None, url: Some(test_url.to_owned()), + data: None, }; let notify_body = NotifyBody { @@ -10341,6 +10407,7 @@ async fn notification_link_multiple_subscribers_different_links( assert_eq!(notification.title, claims1.msg.title); assert_eq!(notification.body, claims1.msg.body); assert_ne!(notification.url.as_ref(), Some(&claims1.msg.url)); + assert_eq!(notification.data, claims1.msg.data); let (_, claims2) = accept_notify_message( &mut relay_client, @@ -10357,6 +10424,7 @@ async fn notification_link_multiple_subscribers_different_links( assert_eq!(notification.title, claims2.msg.title); assert_eq!(notification.body, claims2.msg.body); assert_ne!(notification.url.as_ref(), Some(&claims2.msg.url)); + assert_eq!(notification.data, claims2.msg.data); let result1 = get_notifications( &mut relay_client, @@ -10381,6 +10449,7 @@ async fn notification_link_multiple_subscribers_different_links( assert_eq!(notification.title, gotten_notification1.title); assert_eq!(notification.body, gotten_notification1.body); assert_ne!(notification.url, gotten_notification1.url); + assert_eq!(notification.data, gotten_notification1.data); assert_eq!(gotten_notification1.url.as_ref(), Some(&claims1.msg.url)); @@ -10407,6 +10476,7 @@ async fn notification_link_multiple_subscribers_different_links( assert_eq!(notification.title, gotten_notification2.title); assert_eq!(notification.body, gotten_notification2.body); assert_ne!(notification.url, gotten_notification2.url); + assert_eq!(notification.data, gotten_notification2.data); assert_eq!(gotten_notification2.url.as_ref(), Some(&claims2.msg.url)); @@ -10534,6 +10604,7 @@ async fn mark_notification_as_read() { body: "body".to_owned(), icon: None, url: None, + data: None, }; let notification_with_id = upsert_notification( Uuid::new_v4().to_string(), @@ -10636,6 +10707,7 @@ async fn mark_only_identified_notification_as_read_postgres() { body: "body".to_owned(), icon: None, url: None, + data: None, }; let notification_with_id1 = upsert_notification( Uuid::new_v4().to_string(), @@ -10672,6 +10744,7 @@ async fn mark_only_identified_notification_as_read_postgres() { body: "body".to_owned(), icon: None, url: None, + data: None, }; let notification_with_id2 = upsert_notification( Uuid::new_v4().to_string(), @@ -10777,6 +10850,7 @@ async fn mark_all_notifications_as_read_postgres() { body: "body".to_owned(), icon: None, url: None, + data: None, }; let notification_with_id1 = upsert_notification( Uuid::new_v4().to_string(), @@ -10813,6 +10887,7 @@ async fn mark_all_notifications_as_read_postgres() { body: "body".to_owned(), icon: None, url: None, + data: None, }; let notification_with_id2 = upsert_notification( Uuid::new_v4().to_string(), @@ -10963,6 +11038,7 @@ async fn mark_single_notification_as_read_only_same_subscriber_postgres() { body: "body".to_owned(), icon: None, url: None, + data: None, }; let notification_with_id1 = upsert_notification( Uuid::new_v4().to_string(), @@ -11079,6 +11155,7 @@ async fn mark_all_notifications_as_read_only_same_subscriber_postgres() { body: "body".to_owned(), icon: None, url: None, + data: None, }; let notification_with_id1 = upsert_notification( Uuid::new_v4().to_string(), @@ -11170,6 +11247,7 @@ async fn does_not_mark_already_read_notification_as_read_postgres() { body: "body".to_owned(), icon: None, url: None, + data: None, }; let notification_with_id = upsert_notification( Uuid::new_v4().to_string(), @@ -11302,6 +11380,7 @@ async fn get_subscriptions_by_account_and_maybe_app_unread_count_multiple_scopes body: "body".to_owned(), icon: None, url: None, + data: None, }; let notification_with_id = upsert_notification( Uuid::new_v4().to_string(), @@ -11391,6 +11470,7 @@ async fn get_subscriptions_by_account_and_maybe_app_unread() { body: "body".to_owned(), icon: None, url: None, + data: None, }; let notification_with_id = upsert_notification( Uuid::new_v4().to_string(), @@ -11512,6 +11592,7 @@ async fn e2e_mark_notification_as_read(notify_server: &NotifyServerContext) { body: "body".to_owned(), icon: None, url: None, + data: None, }; let notify_body = NotifyBody { notification_id: None,