Handles post processing logic like sending notifications.
(&self, request: &Request)
| 390 | |
| 391 | /// Handles post processing logic like sending notifications. |
| 392 | async fn created_request_hook(&self, request: &Request) { |
| 393 | let mut possible_approvers = match request.find_all_possible_approvers().await { |
| 394 | Ok(approvers) => approvers, |
| 395 | Err(_) => { |
| 396 | print(format!( |
| 397 | "Failed to find all possible approvers for request {}", |
| 398 | Uuid::from_bytes(request.id).hyphenated() |
| 399 | )); |
| 400 | return; |
| 401 | } |
| 402 | }; |
| 403 | |
| 404 | possible_approvers.remove(&request.requested_by); |
| 405 | |
| 406 | for approver in possible_approvers { |
| 407 | self.notification_service |
| 408 | .send_notification( |
| 409 | approver, |
| 410 | NotificationType::RequestCreated(RequestCreatedNotification { |
| 411 | request_id: request.id, |
| 412 | }), |
| 413 | request.title.to_owned(), |
| 414 | request.summary.to_owned(), |
| 415 | ) |
| 416 | .await; |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | /// Cancels a request if the request is in the created status and the caller is the requester. |
| 421 | pub fn cancel_request( |
no test coverage detected