From a05fa30e8d91b9b4169319bc8536ebfb7510267b Mon Sep 17 00:00:00 2001 From: dzak27567 <fadhlurohmandzaki@gmail.com> Date: Thu, 27 Mar 2025 14:08:40 +0700 Subject: [PATCH] Implement receive_notification function in Notification service. --- src/service/notification.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/service/notification.rs b/src/service/notification.rs index f5e5494..7867c4b 100644 --- a/src/service/notification.rs +++ b/src/service/notification.rs @@ -5,7 +5,7 @@ use rocket::serde::json::to_string; use rocket::tokio; use bambangshop_receiver::{APP_CONFIG, REQWEST_CLIENT, Result, compose_error_response}; - +use crate::model::notification::Notification; use crate::model::subscriber::SubscriberRequest; use crate::repository::notification::NotificationRepository; @@ -59,7 +59,7 @@ impl NotificationService { return thread::spawn(move || Self::unsubscribe_request(product_type_clone)) .join().unwrap(); } - + #[tokio::main] async fn unsubscribe_request(product_type: String) -> Result<SubscriberRequest> { let product_type_upper: String = product_type.to_uppercase(); @@ -91,5 +91,10 @@ impl NotificationService { } } + pub fn receive_notification(payload: Notification) -> Result<Notification> { + let subscriber_result: Notification = NotificationRepository::add(payload); + return Ok(subscriber_result); + } + } \ No newline at end of file -- GitLab