| 1544 | } |
| 1545 | |
| 1546 | async fn get_ifttt_integration( |
| 1547 | &self, |
| 1548 | request: Request<api::GetIftttIntegrationRequest>, |
| 1549 | ) -> Result<Response<api::GetIftttIntegrationResponse>, Status> { |
| 1550 | let req = request.get_ref(); |
| 1551 | let app_id = Uuid::from_str(&req.application_id).map_err(|e| e.status())?; |
| 1552 | |
| 1553 | self.validator |
| 1554 | .validate( |
| 1555 | request.extensions(), |
| 1556 | validator::ValidateApplicationAccess::new(validator::Flag::Read, app_id), |
| 1557 | ) |
| 1558 | .await?; |
| 1559 | |
| 1560 | let i = application::get_integration(&app_id, application::IntegrationKind::Ifttt) |
| 1561 | .await |
| 1562 | .map_err(|e| e.status())?; |
| 1563 | |
| 1564 | if let application::IntegrationConfiguration::Ifttt(conf) = &i.configuration { |
| 1565 | let mut resp = Response::new(api::GetIftttIntegrationResponse { |
| 1566 | integration: Some(api::IftttIntegration { |
| 1567 | application_id: app_id.to_string(), |
| 1568 | key: conf.key.clone(), |
| 1569 | uplink_values: conf.uplink_values.to_vec(), |
| 1570 | arbitrary_json: conf.arbitrary_json, |
| 1571 | event_prefix: conf.event_prefix.clone(), |
| 1572 | }), |
| 1573 | }); |
| 1574 | resp.metadata_mut() |
| 1575 | .insert("x-log-application_id", req.application_id.parse().unwrap()); |
| 1576 | |
| 1577 | Ok(resp) |
| 1578 | } else { |
| 1579 | Err(Status::internal("Integration has no Ifttt configuration")) |
| 1580 | } |
| 1581 | } |
| 1582 | |
| 1583 | async fn update_ifttt_integration( |
| 1584 | &self, |