Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit 81071edd authored by Ida Made Revindra Dikta Mahendra's avatar Ida Made Revindra Dikta Mahendra
Browse files

[CHORE]: Implement notify function in Notification service to notify each Subscriber

parent 797ebad5
No related branches found
No related tags found
No related merge requests found
......@@ -29,4 +29,22 @@ impl NotificationService {
}
return Ok(result.unwrap());
}
pub fn notify(&self, product_type: &str, status: &str, product: Product){
let mut payload: Notification= Notification{
product_title: product.clone().title,
product_type: String::from(product_type),
product_url: product.clone().get_url(),
subscriber_name: String::from(""),
status: String::from(status)
};
let subscribers: Vec<Subscriber> = SubscriberRepository::list_all(product_type);
for subscriber in subscribers{
payload.subscriber_name = subscriber.clone().name;
let subscriber_clone = subscriber.clone();
let payload_clone = payload.clone();
thread::spawn(move || subscriber_clone.update(payload_clone));
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment