| 1694 | } |
| 1695 | |
| 1696 | async fn get_blynk_integration( |
| 1697 | &self, |
| 1698 | request: Request<api::GetBlynkIntegrationRequest>, |
| 1699 | ) -> Result<Response<api::GetBlynkIntegrationResponse>, Status> { |
| 1700 | let req = request.get_ref(); |
| 1701 | let app_id = Uuid::from_str(&req.application_id).map_err(|e| e.status())?; |
| 1702 | |
| 1703 | self.validator |
| 1704 | .validate( |
| 1705 | request.extensions(), |
| 1706 | validator::ValidateApplicationAccess::new(validator::Flag::Read, app_id), |
| 1707 | ) |
| 1708 | .await?; |
| 1709 | |
| 1710 | let i = application::get_integration(&app_id, application::IntegrationKind::Blynk) |
| 1711 | .await |
| 1712 | .map_err(|e| e.status())?; |
| 1713 | |
| 1714 | if let application::IntegrationConfiguration::Blynk(conf) = &i.configuration { |
| 1715 | let mut resp = Response::new(api::GetBlynkIntegrationResponse { |
| 1716 | integration: Some(api::BlynkIntegration { |
| 1717 | application_id: app_id.to_string(), |
| 1718 | token: conf.token.clone(), |
| 1719 | }), |
| 1720 | }); |
| 1721 | resp.metadata_mut() |
| 1722 | .insert("x-log-application_id", req.application_id.parse().unwrap()); |
| 1723 | |
| 1724 | Ok(resp) |
| 1725 | } else { |
| 1726 | Err(Status::internal("Integration has no Blynk configuration")) |
| 1727 | } |
| 1728 | } |
| 1729 | |
| 1730 | async fn update_blynk_integration( |
| 1731 | &self, |