Skip to content

Commit

Permalink
Implement refresh full template support
Browse files Browse the repository at this point in the history
  • Loading branch information
sagojez committed Apr 15, 2024
1 parent 44cfb73 commit 60cdf8b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
6 changes: 4 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dotenvy = "0.15.7"
envconfig = "0.10.0"
futures = "0.3.30"
handlebars = "5.1.1"
integrationos-domain = { version = "1.3.0", features = ["dummy", "actix-error"] }
integrationos-domain = { version = "2.1.0", features = ["dummy", "actix-error"] }
jsonwebtoken = "9.2.0"
moka = { version = "0.12.5", features = ["future"] }
mongodb = "2.8.0"
Expand Down
6 changes: 3 additions & 3 deletions src/algebra/refresh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use actix::prelude::*;
use chrono::{Duration, Utc};
use futures::lock::Mutex;
use integrationos_domain::{
algebra::MongoStore, connection_oauth_definition::ConnectionOAuthDefinition,
error::IntegrationOSError as Error, service::secrets_client::SecretsClient, Connection,
InternalError,
algebra::MongoStore, client::secrets_client::SecretsClient,
connection_oauth_definition::ConnectionOAuthDefinition, error::IntegrationOSError as Error,
Connection, InternalError,
};
use reqwest::Client;
use std::sync::Arc;
Expand Down
12 changes: 10 additions & 2 deletions src/algebra/trigger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ use chrono::Duration;
use integrationos_domain::{
algebra::{MongoStore, StoreExt},
api_model_config::ContentType,
client::secrets_client::SecretsClient,
connection_oauth_definition::{Computation, ConnectionOAuthDefinition, OAuthResponse},
error::IntegrationOSError as Error,
get_secret_request::GetSecretRequest,
oauth_secret::OAuthSecret,
service::secrets_client::SecretsClient,
ApplicationError, Connection, Id, InternalError, OAuth,
ApplicationError, Connection, DefaultTemplate, Id, InternalError, OAuth, TemplateExt,
};
use mongodb::bson::{self, doc};
use reqwest::Client;
Expand Down Expand Up @@ -75,6 +75,8 @@ impl Handler<Trigger> for TriggerActor {
let request_id = self.request_id.map(|id| id.to_string());

let future = async move {
let template = DefaultTemplate::default();

let ask = || async {
let conn_id = match &msg.connection().oauth {
Some(OAuth::Enabled {
Expand Down Expand Up @@ -123,6 +125,12 @@ impl Handler<Trigger> for TriggerActor {
InternalError::serialize_error("Failed to serialize secret", None)
})?;

let conn_oauth_definition = if conn_oauth_definition.is_full_template_enabled {
template.render_as(&conn_oauth_definition, Some(&compute_payload))?
} else {
conn_oauth_definition
};

let computation = conn_oauth_definition
.compute
.refresh
Expand Down
6 changes: 3 additions & 3 deletions src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ pub use http::*;
use crate::prelude::RefreshActor;
use actix::{Addr, Supervisor};
use integrationos_domain::{
algebra::MongoStore, connection_oauth_definition::ConnectionOAuthDefinition,
error::IntegrationOSError as Error, event_access::EventAccess,
service::secrets_client::SecretsClient, Connection, InternalError, Store,
algebra::MongoStore, client::secrets_client::SecretsClient,
connection_oauth_definition::ConnectionOAuthDefinition, error::IntegrationOSError as Error,
event_access::EventAccess, Connection, InternalError, Store,
};
use moka::future::Cache;
use mongodb::options::FindOptions;
Expand Down

0 comments on commit 60cdf8b

Please sign in to comment.