From 92720201c1069219622d4bc88b9ee79e7ca09946 Mon Sep 17 00:00:00 2001 From: dzak27567 <fadhlurohmandzaki@gmail.com> Date: Thu, 27 Mar 2025 14:23:28 +0700 Subject: [PATCH] Implement list function in Notification controller. --- src/controller/mod.rs | 2 +- src/controller/notification.rs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/controller/mod.rs b/src/controller/mod.rs index 25cc704..d6e6fdf 100644 --- a/src/controller/mod.rs +++ b/src/controller/mod.rs @@ -4,7 +4,7 @@ pub fn route_stage() -> AdHoc { return AdHoc::on_ignite("Initializing controller routes...", |rocket| async { rocket .mount("/", routes![notification::subscribe, notification::unsubscribe, - notification::receive]) + notification::receive, notification::list]) }); } diff --git a/src/controller/notification.rs b/src/controller/notification.rs index 5a5cf58..4b2e4e7 100644 --- a/src/controller/notification.rs +++ b/src/controller/notification.rs @@ -27,4 +27,12 @@ pub fn receive(notification: Json<Notification>) -> Result<Json<Notification>> { Ok(f) => Ok(Json::from(f)), Err(e) => Err(e) }; +} + +#[get("/")] +pub fn list() -> Result<Json<Vec<String>>> { + return match NotificationService::list_messages() { + Ok(f) => Ok(Json::from(f)), + Err(e) => Err(e) + }; } \ No newline at end of file -- GitLab