(
&self,
input: ListNotificationsInput,
)
| 45 | |
| 46 | #[with_middleware(guard = authorize(&call_context(), &[Resource::from(&input)]))] |
| 47 | async fn list_notifications( |
| 48 | &self, |
| 49 | input: ListNotificationsInput, |
| 50 | ) -> ApiResult<ListNotificationsResponse> { |
| 51 | let notifications = self |
| 52 | .notification_service |
| 53 | .list_notifications(input, &call_context())? |
| 54 | .into_iter() |
| 55 | .fold(Vec::new(), |mut acc, notification| { |
| 56 | match NotificationDTO::try_from(notification) { |
| 57 | Ok(notification_dto) => acc.push(notification_dto), |
| 58 | Err(error) => match error { |
| 59 | NotificationMapperError::RequestNotFound { request_id } => { |
| 60 | print(format!( |
| 61 | "Request {} not found when mapping to NotificationDTO", |
| 62 | Uuid::from_bytes(request_id).hyphenated() |
| 63 | )); |
| 64 | } |
| 65 | NotificationMapperError::InvalidRequestStatus { |
| 66 | expected, found |
| 67 | } => { |
| 68 | print(format!("Invalid request status when mapping to NotificationDTO: expected \"{expected}\", found \"{found}\"")); |
| 69 | } |
| 70 | }, |
| 71 | } |
| 72 | |
| 73 | acc |
| 74 | }); |
| 75 | |
| 76 | Ok(ListNotificationsResponse { notifications }) |
| 77 | } |
| 78 | |
| 79 | #[with_middleware(guard = authorize(&call_context(), &MarkNotificationsReadInputRef(&input).to_resources()))] |
| 80 | #[with_middleware(tail = use_canister_call_metric("mark_notifications_read", &result))] |
no test coverage detected