Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit e2846fb6 authored by Christian Raphael Heryanto's avatar Christian Raphael Heryanto
Browse files

Implement unsubscribe function in Notification service.

parent 1bb7ff94
No related branches found
No related tags found
No related merge requests found
...@@ -16,4 +16,17 @@ impl NotificationService { ...@@ -16,4 +16,17 @@ impl NotificationService {
let subscriber_result: Subscriber = SubscriberRepository::add(product_type_str, subscriber); let subscriber_result: Subscriber = SubscriberRepository::add(product_type_str, subscriber);
return Ok(subscriber_result); return Ok(subscriber_result);
} }
pub fn unsubscribe(product_type: &str, url: &str) -> Result<Subscriber> {
let product_type_upper: String = product_type.to_uppercase();
let product_type_str: &str = product_type_upper.as_str();
let result: Option<Subscriber> = SubscriberRepository::delete(product_type_str, url);
if result.is_none() {
return Err(compose_error_response(
Status::NotFound,
String::from("Subscriber not found"),
));
}
return Ok(result.unwrap());
}
} }
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