From d852e8c4c6e1962d26c30cdadc633578ef9689b0 Mon Sep 17 00:00:00 2001 From: rafliesa <rflisaa@gmail.com> Date: Fri, 28 Mar 2025 19:22:30 +0700 Subject: [PATCH] Implement the receive function in Notification controller. --- src/controller/mod.rs | 3 ++- src/controller/notification.rs | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/controller/mod.rs b/src/controller/mod.rs index 3f1e755..dbb820f 100644 --- a/src/controller/mod.rs +++ b/src/controller/mod.rs @@ -5,6 +5,7 @@ pub mod notification; pub fn route_stage() -> AdHoc { return AdHoc::on_ignite("Initializing controller routes...", |rocket| async { rocket - .mount("/", routes![notification::subscribe, notification::unsubscribe]) + .mount("/", routes![notification::subscribe, notification::unsubscribe, + notification::receive]) }); } diff --git a/src/controller/notification.rs b/src/controller/notification.rs index fe291ee..1b7e27b 100644 --- a/src/controller/notification.rs +++ b/src/controller/notification.rs @@ -19,4 +19,12 @@ pub fn unsubscribe(product_type: &str) -> Result<Json<SubscriberRequest>> { Ok(f) => Ok(Json::from(f)), Err(e) => Err(e) }; +} + +#[post("/receive", data = "<notification>")] +pub fn receive(notification: Json<Notification>) -> Result<Json<Notification>> { + return match NotificationService::receive_notification(notification.into_inner()) { + Ok(f) => Ok(Json::from(f)), + Err(e) => Err(e) + }; } \ No newline at end of file -- GitLab