Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit ff9a9b71 authored by Scallss's avatar Scallss
Browse files

Implement notify function in Notification service to notify each Subscriber.

parent a6047dc2
No related branches found
No related tags found
No related merge requests found
......@@ -32,5 +32,24 @@ 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.
Finish editing this message first!
Please register or to comment