From f678dc435b83dee0d462d8ae27f6c5b4867c7d4f Mon Sep 17 00:00:00 2001 From: Andrew4Coding <andrewdevitoaryo@gmail.com> Date: Fri, 28 Mar 2025 12:08:04 +0800 Subject: [PATCH] Implement add function in Subscriber repository --- src/repository/notification.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/repository/notification.rs b/src/repository/notification.rs index 7ccb816..3a1393e 100644 --- a/src/repository/notification.rs +++ b/src/repository/notification.rs @@ -1,14 +1,19 @@ +use std::sync::RwLock; + use lazy_static::lazy_static; -use rocket::tokio::sync::RwLock; use crate::model::notification::Notification; lazy_static! { - static ref NOIIFICATIONS: RwLock<Vec<Notification>> = RwLock::new(Vec::new()); + static ref NOTIFICATIONS: RwLock<Vec<Notification>> = RwLock::new(Vec::new()); } pub struct NotificationRepository; impl NotificationRepository { + pub async fn add_notification(notification: Notification) -> Notification { + NOTIFICATIONS.write().unwrap().push(notification.clone()); + notification + } } \ No newline at end of file -- GitLab