diff --git a/src/model/subscriber.rs b/src/model/subscriber.rs index f067e84ff8793436e87f4475c97901200a4ea1c7..bcea228309ef460e72f2ee4f428e6f36735e5eec 100644 --- a/src/model/subscriber.rs +++ b/src/model/subscriber.rs @@ -1,4 +1,3 @@ - use rocket::serde::{Deserialize, Serialize}; use rocket::log; use rocket::serde::json::to_string; @@ -11,4 +10,17 @@ use crate::model::notification::Notification; pub struct Subscriber { pub url: String, pub name: String, +} + +impl Subscriber{ + #[tokio::main] + pub async fn update(&self, payload: Notification){ + REQWEST_CLIENT + .post(&self.url) + .header("Content-Type", "JSON") + .body(to_string(&payload).unwrap()) + .send().await.ok(); + log::warn_!("Sent {} notification of: [{}] {}, to: {}", + payload.status, payload.product_type, payload.product_title, self.url); + } } \ No newline at end of file