diff --git a/src/service/notification.rs b/src/service/notification.rs index f5e5494b4a6915e311d5b551a5a05f2999bd9557..7867c4b3aceb9eaa4e2f980ea796a3868c1a143b 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