| 1581 | } |
| 1582 | |
| 1583 | async fn update_ifttt_integration( |
| 1584 | &self, |
| 1585 | request: Request<api::UpdateIftttIntegrationRequest>, |
| 1586 | ) -> Result<Response<()>, Status> { |
| 1587 | let req_int = match &request.get_ref().integration { |
| 1588 | Some(v) => v, |
| 1589 | None => { |
| 1590 | return Err(Status::invalid_argument("integration is missing")); |
| 1591 | } |
| 1592 | }; |
| 1593 | let app_id = Uuid::from_str(&req_int.application_id).map_err(|e| e.status())?; |
| 1594 | |
| 1595 | self.validator |
| 1596 | .validate( |
| 1597 | request.extensions(), |
| 1598 | validator::ValidateApplicationAccess::new(validator::Flag::Update, app_id), |
| 1599 | ) |
| 1600 | .await?; |
| 1601 | |
| 1602 | let _ = application::update_integration(application::Integration { |
| 1603 | application_id: app_id.into(), |
| 1604 | kind: application::IntegrationKind::Ifttt, |
| 1605 | configuration: application::IntegrationConfiguration::Ifttt( |
| 1606 | application::IftttConfiguration { |
| 1607 | key: req_int.key.clone(), |
| 1608 | uplink_values: [ |
| 1609 | req_int.uplink_values.first().cloned().unwrap_or_default(), |
| 1610 | req_int.uplink_values.get(1).cloned().unwrap_or_default(), |
| 1611 | ], |
| 1612 | arbitrary_json: req_int.arbitrary_json, |
| 1613 | event_prefix: req_int.event_prefix.clone(), |
| 1614 | }, |
| 1615 | ), |
| 1616 | ..Default::default() |
| 1617 | }) |
| 1618 | .await |
| 1619 | .map_err(|e| e.status())?; |
| 1620 | |
| 1621 | let mut resp = Response::new(()); |
| 1622 | resp.metadata_mut().insert( |
| 1623 | "x-log-application_id", |
| 1624 | req_int.application_id.parse().unwrap(), |
| 1625 | ); |
| 1626 | |
| 1627 | Ok(resp) |
| 1628 | } |
| 1629 | |
| 1630 | async fn delete_ifttt_integration( |
| 1631 | &self, |