diff --git a/core/notifications/src/app/mod.rs b/core/notifications/src/app/mod.rs index 0afd572f5a..035b7850f9 100644 --- a/core/notifications/src/app/mod.rs +++ b/core/notifications/src/app/mod.rs @@ -149,52 +149,10 @@ impl NotificationsApp { Ok(user_settings) } - #[instrument(name = "app.handle_circle_grew", skip(self), err)] - pub async fn handle_circle_grew(&self, event: CircleGrew) -> Result<(), ApplicationError> { - self.executor.notify(event).await?; - Ok(()) - } - - #[instrument(name = "app.handle_threshold_reached", skip(self), err)] - pub async fn handle_threshold_reached( - &self, - event: CircleThresholdReached, - ) -> Result<(), ApplicationError> { - self.executor.notify(event).await?; - Ok(()) - } - - #[instrument(name = "app.handle_documents_submitted", skip(self), err)] - pub async fn handle_documents_submitted( - &self, - event: DocumentsSubmitted, - ) -> Result<(), ApplicationError> { - self.executor.notify(event).await?; - Ok(()) - } - - #[instrument(name = "app.handle_documents_approved", skip(self), err)] - pub async fn handle_documents_approved( - &self, - event: DocumentsApproved, - ) -> Result<(), ApplicationError> { - self.executor.notify(event).await?; - Ok(()) - } - - #[instrument(name = "app.handle_documents_rejected", skip(self), err)] - pub async fn handle_documents_rejected( - &self, - event: DocumentsRejected, - ) -> Result<(), ApplicationError> { - self.executor.notify(event).await?; - Ok(()) - } - - #[instrument(name = "app.handle_documents_review_pending", skip(self), err)] - pub async fn handle_documents_review_pending( + #[instrument(name = "app.handle_notification_event", skip(self), err)] + pub async fn handle_notification_event( &self, - event: DocumentsReviewPending, + event: T, ) -> Result<(), ApplicationError> { self.executor.notify(event).await?; Ok(()) diff --git a/core/notifications/src/grpc/server/mod.rs b/core/notifications/src/grpc/server/mod.rs index 50762efb9d..76024d8797 100644 --- a/core/notifications/src/grpc/server/mod.rs +++ b/core/notifications/src/grpc/server/mod.rs @@ -251,7 +251,7 @@ impl NotificationsService for Notifications { .map(primitives::CircleType::from) .map_err(|e| Status::invalid_argument(e.to_string()))?; self.app - .handle_circle_grew(notification_event::CircleGrew { + .handle_notification_event(notification_event::CircleGrew { user_id: GaloyUserId::from(user_id), circle_type, this_month_circle_size, @@ -277,7 +277,7 @@ impl NotificationsService for Notifications { .map(primitives::CircleTimeFrame::from) .map_err(|e| Status::invalid_argument(e.to_string()))?; self.app - .handle_threshold_reached(notification_event::CircleThresholdReached { + .handle_notification_event(notification_event::CircleThresholdReached { user_id: GaloyUserId::from(user_id), circle_type, time_frame, @@ -292,7 +292,7 @@ impl NotificationsService for Notifications { )), }) => { self.app - .handle_documents_submitted(notification_event::DocumentsSubmitted { + .handle_notification_event(notification_event::DocumentsSubmitted { user_id: GaloyUserId::from(user_id), }) .await? @@ -304,7 +304,7 @@ impl NotificationsService for Notifications { })), }) => { self.app - .handle_documents_approved(notification_event::DocumentsApproved { + .handle_notification_event(notification_event::DocumentsApproved { user_id: GaloyUserId::from(user_id), }) .await? @@ -316,7 +316,7 @@ impl NotificationsService for Notifications { })), }) => { self.app - .handle_documents_rejected(notification_event::DocumentsRejected { + .handle_notification_event(notification_event::DocumentsRejected { user_id: GaloyUserId::from(user_id), }) .await? @@ -328,7 +328,7 @@ impl NotificationsService for Notifications { )), }) => { self.app - .handle_documents_review_pending(notification_event::DocumentsReviewPending { + .handle_notification_event(notification_event::DocumentsReviewPending { user_id: GaloyUserId::from(user_id), }) .await? diff --git a/core/notifications/src/notification_event.rs b/core/notifications/src/notification_event.rs index fa859ea4a7..2c0e02daf1 100644 --- a/core/notifications/src/notification_event.rs +++ b/core/notifications/src/notification_event.rs @@ -13,7 +13,7 @@ pub struct CircleGrew { pub all_time_circle_size: u32, } -pub trait NotificationEvent { +pub trait NotificationEvent: std::fmt::Debug { fn user_id(&self) -> &GaloyUserId; fn deep_link(&self) -> DeepLink; fn to_localized_msg(&self, locale: GaloyLocale) -> LocalizedMessage;