Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(comms): remove internal adapter (#1733)
Sean Aye4c11c92271df
diff --git a/rust/cloud-storage/Cargo.lock b/rust/cloud-storage/Cargo.lockindex cd3d723cca..b56af7d669 100644--- a/rust/cloud-storage/Cargo.lock+++ b/rust/cloud-storage/Cargo.lock@@ -1926,7 +1926,6 @@ dependencies = ["models_comms","models_pagination","recursion",- "reqwest","rootcause","serde","serde_json",diff --git a/rust/cloud-storage/ai_tools/src/tool_context.rs b/rust/cloud-storage/ai_tools/src/tool_context.rsindex c7489516c6..03e4baeec5 100644--- a/rust/cloud-storage/ai_tools/src/tool_context.rs+++ b/rust/cloud-storage/ai_tools/src/tool_context.rs@@ -1,7 +1,7 @@use axum::extract::FromRef;use comms::{domain::service::ChannelServiceImpl,- outbound::{http::user_repo::UserRepoImpl, postgres::comms_repo::PgCommsRepo},+ outbound::postgres::{comms_repo::PgCommsRepo, user_repo::PgUserRepo},};use email::{domain::service::EmailServiceImpl, outbound::EmailPgRepo};use frecency::{domain::services::FrecencyQueryServiceImpl, outbound::postgres::FrecencyPgStorage};@@ -27,7 +27,7 @@ pub type ToolFrecencyService = FrecencyQueryServiceImpl<FrecencyPgStorage>;pub type ToolEmailService = EmailServiceImpl<EmailPgRepo, ToolFrecencyService>;/// Type alias for the comms/channels service implementation-pub type ToolCommsService = ChannelServiceImpl<PgCommsRepo, UserRepoImpl, FrecencyPgStorage>;+pub type ToolCommsService = ChannelServiceImpl<PgCommsRepo, PgUserRepo, FrecencyPgStorage>;/// Type alias for the soup service implementationpub type ToolSoupService =diff --git a/rust/cloud-storage/comms/Cargo.toml b/rust/cloud-storage/comms/Cargo.tomlindex e2a3cf0f3b..3c08d41b91 100644--- a/rust/cloud-storage/comms/Cargo.toml+++ b/rust/cloud-storage/comms/Cargo.toml@@ -5,8 +5,8 @@ publish = falseversion = "0.1.0"[features]-inbound = ["dep:axum", "dep:model_user", "dep:reqwest", "dep:utoipa"]-outbound = ["dep:reqwest"]+inbound = ["dep:axum", "dep:model_user", "dep:utoipa"]+outbound = [][dependencies]@@ -22,7 +22,6 @@ model_user = { path = "../model_user", optional = true, features = ["axum"] }models_comms = { path = "../models_comms" }models_pagination = { path = "../models_pagination" }recursion = { workspace = true }-reqwest = { workspace = true, optional = true }rootcause = { workspace = true }serde = { workspace = true }serde_json = { workspace = true }diff --git a/rust/cloud-storage/comms/src/outbound.rs b/rust/cloud-storage/comms/src/outbound.rsindex 921cda0f97..26e9103cd5 100644--- a/rust/cloud-storage/comms/src/outbound.rs+++ b/rust/cloud-storage/comms/src/outbound.rs@@ -1,2 +1 @@-pub mod http;pub mod postgres;diff --git a/rust/cloud-storage/comms/src/outbound/http/user_repo.rs b/rust/cloud-storage/comms/src/outbound/http/user_repo.rsdeleted file mode 100644index cd1b256476..0000000000--- a/rust/cloud-storage/comms/src/outbound/http/user_repo.rs+++ /dev/null@@ -1,74 +0,0 @@-use crate::domain::{models::UserName, ports::UserRepo};-use macro_user_id::user_id::MacroUserIdStr;-use reqwest::Url;-use rootcause::report;-use serde::Deserialize;-use std::{collections::HashSet, sync::Arc};--#[derive(Clone)]-pub struct UserRepoImpl {- url: Arc<Url>,- client: reqwest::Client,-}--pub static INTERNAL_AUTH_HEADER_KEY: &str = "x-internal-auth-key";--impl UserRepoImpl {- pub fn new(internal_auth_key: String, url: Url) -> Self {- let mut headers = reqwest::header::HeaderMap::new();- headers.insert(INTERNAL_AUTH_HEADER_KEY, internal_auth_key.parse().unwrap());-- let client = reqwest::Client::builder()- .default_headers(headers)- .build()- .unwrap();-- Self {- url: Arc::new(url),- client,- }- }-}--#[derive(Debug, serde::Serialize)]-pub struct PostGetNamesRequestBody<'a> {- pub user_ids: HashSet<MacroUserIdStr<'a>>,-}--#[derive(Deserialize, Debug)]-pub struct UserNames {- pub names: Vec<UserName>,-}--impl UserRepo for UserRepoImpl {- #[tracing::instrument(err, skip(self, user_ids))]- async fn get_names_for_ids(- &self,- user_ids: std::collections::HashSet<macro_user_id::user_id::MacroUserIdStr<'_>>,- ) -> Result<Vec<UserName>, rootcause::Report> {- let body = PostGetNamesRequestBody { user_ids };-- let mut url = self.url.as_ref().clone();- url.set_path("/internal/get_names");-- let res = self.client.post(url).json(&body).send().await.inspect_err(- |e| tracing::error!(error=?e, "failed to get names from authentication service"),- )?;-- match res.status() {- reqwest::StatusCode::OK => {- let result = res.json::<UserNames>().await?;- Ok(result.names)- }- status_code => {- let body: String = res.text().await?;- tracing::error!(- body=%body,- status=%status_code,- "unexpected response from authentication service"- );- Err(report!(body).into())- }- }- }-}diff --git a/rust/cloud-storage/comms_service/src/api/context.rs b/rust/cloud-storage/comms_service/src/api/context.rsindex b3800f79cb..9312a98af2 100644--- a/rust/cloud-storage/comms_service/src/api/context.rs+++ b/rust/cloud-storage/comms_service/src/api/context.rs@@ -2,7 +2,7 @@ use axum_macros::FromRef;use comms::{domain::service::ChannelServiceImpl,inbound::CommsRouterState,- outbound::{http::user_repo::UserRepoImpl, postgres::comms_repo::PgCommsRepo},+ outbound::postgres::{comms_repo::PgCommsRepo, user_repo::PgUserRepo},};use connection_gateway_client::client::ConnectionGatewayClient;use frecency::outbound::postgres::FrecencyPgStorage;@@ -52,4 +52,4 @@ pub struct AppState {pub comms_state: CommsRouterState<ChannelImpl>,}-pub type ChannelImpl = ChannelServiceImpl<PgCommsRepo, UserRepoImpl, FrecencyPgStorage>;+pub type ChannelImpl = ChannelServiceImpl<PgCommsRepo, PgUserRepo, FrecencyPgStorage>;diff --git a/rust/cloud-storage/comms_service/src/lib.rs b/rust/cloud-storage/comms_service/src/lib.rsindex 71802397f3..c3b7c7055e 100644--- a/rust/cloud-storage/comms_service/src/lib.rs+++ b/rust/cloud-storage/comms_service/src/lib.rs@@ -18,6 +18,6 @@ pub use api::swagger::ApiDoc as CommsApiDoc;// Re-export comms types needed to construct the statepub use comms::domain::service::ChannelServiceImpl;pub use comms::inbound::CommsRouterState;-pub use comms::outbound::http::user_repo::UserRepoImpl;pub use comms::outbound::postgres::comms_repo::PgCommsRepo;+pub use comms::outbound::postgres::user_repo::PgUserRepo;pub use frecency::outbound::postgres::FrecencyPgStorage;diff --git a/rust/cloud-storage/document_cognition_service/src/api/context/test.rs b/rust/cloud-storage/document_cognition_service/src/api/context/test.rsindex 6bcfdc9c9f..085f343b43 100644--- a/rust/cloud-storage/document_cognition_service/src/api/context/test.rs+++ b/rust/cloud-storage/document_cognition_service/src/api/context/test.rs@@ -109,8 +109,8 @@ impl StreamRepo for MockStreamRepo {pub async fn test_api_context(pool: sqlx::Pool<sqlx::Postgres>) -> std::sync::Arc<ApiContext> {use aws_sdk_sqs;use comms::domain::service::ChannelServiceImpl;- use comms::outbound::http::user_repo::UserRepoImpl;use comms::outbound::postgres::comms_repo::PgCommsRepo;+ use comms::outbound::postgres::user_repo::PgUserRepo;use comms_service_client::CommsServiceClient;use document_cognition_service_client::DocumentCognitionServiceClient;use document_storage_service_client::DocumentStorageServiceClient;@@ -194,7 +194,7 @@ pub async fn test_api_context(pool: sqlx::Pool<sqlx::Postgres>) -> std::sync::Arlet frecency_service = FrecencyQueryServiceImpl::new(frecency_storage.clone());let email_service =EmailServiceImpl::new(EmailPgRepo::new(pool.clone()), frecency_service.clone());- let user_repo = UserRepoImpl::new("dummy_auth_key".into(), "http://localhost".parse().unwrap());+ let user_repo = PgUserRepo::new(pool.clone());let channels_service = ChannelServiceImpl::new(PgCommsRepo { pool: pool.clone() },user_repo,diff --git a/rust/cloud-storage/document_cognition_service/src/main.rs b/rust/cloud-storage/document_cognition_service/src/main.rsindex abafa6afeb..a2218059e6 100644--- a/rust/cloud-storage/document_cognition_service/src/main.rs+++ b/rust/cloud-storage/document_cognition_service/src/main.rs@@ -1,8 +1,8 @@use crate::api::context::ApiContext;use anyhow::Context;use comms::domain::service::ChannelServiceImpl;-use comms::outbound::http::user_repo::UserRepoImpl;use comms::outbound::postgres::comms_repo::PgCommsRepo;+use comms::outbound::postgres::user_repo::PgUserRepo;use comms_service_client::CommsServiceClient;use config::{Config, EnvVars, Environment};use document_cognition_service_client::DocumentCognitionServiceClient;@@ -147,31 +147,14 @@ async fn main() -> anyhow::Result<()> {tracing::info!("initialized static file service client");- // Get auth service secret key for soup service- let auth_service_secret_key = match config.environment {- Environment::Local => config.authentication_service_secret_key.clone(),- _ => secretsmanager_client- .get_secret_value(&config.authentication_service_secret_key)- .await- .context("failed to get auth service secret key from secrets manager")?- .to_string(),- };-// Build soup servicelet frecency_storage = FrecencyPgStorage::new(db.clone());let frecency_service = FrecencyQueryServiceImpl::new(frecency_storage.clone());let email_service =EmailServiceImpl::new(EmailPgRepo::new(db.clone()), frecency_service.clone());- let user_repo = UserRepoImpl::new(- auth_service_secret_key,- config- .authentication_service_url- .parse()- .context("AUTHENTICATION_SERVICE_URL must be a valid url")?,- );let channels_service = ChannelServiceImpl::new(PgCommsRepo { pool: db.clone() },- user_repo,+ PgUserRepo::new(db.clone()),frecency_storage,);let soup_service = Arc::new(SoupImpl::new(diff --git a/rust/cloud-storage/document_storage_service/src/api/context.rs b/rust/cloud-storage/document_storage_service/src/api/context.rsindex ed3b6ae567..1fc9454f70 100644--- a/rust/cloud-storage/document_storage_service/src/api/context.rs+++ b/rust/cloud-storage/document_storage_service/src/api/context.rs@@ -8,7 +8,7 @@ use channels::{use comms::{domain::service::ChannelServiceImpl,inbound::CommsRouterState,- outbound::{http::user_repo::UserRepoImpl, postgres::comms_repo::PgCommsRepo},+ outbound::postgres::{comms_repo::PgCommsRepo, user_repo::PgUserRepo},};use comms_service::CommsHandlerState;use connection_gateway_client::client::ConnectionGatewayClient;@@ -59,7 +59,7 @@ type DssSoupState = SoupRouterState<PgSoupRepo,FrecencyQueryServiceImpl<FrecencyPgStorage>,EmailServiceImpl<EmailPgRepo, FrecencyQueryServiceImpl<FrecencyPgStorage>>,- ChannelServiceImpl<PgCommsRepo, UserRepoImpl, FrecencyPgStorage>,+ ChannelServiceImpl<PgCommsRepo, PgUserRepo, FrecencyPgStorage>,>,EmailServiceImpl<EmailPgRepo, FrecencyQueryServiceImpl<FrecencyPgStorage>>,>;@@ -108,7 +108,7 @@ pub(crate) type DocumentsState = DocumentRouterState</// Type alias for the ChannelServiceImpl used by commspub(crate) type CommsChannelService =- ChannelServiceImpl<PgCommsRepo, UserRepoImpl, FrecencyPgStorage>;+ ChannelServiceImpl<PgCommsRepo, PgUserRepo, FrecencyPgStorage>;/// Type alias for the CommsRouterStatepub(crate) type CommsState = CommsRouterState<CommsChannelService>;diff --git a/rust/cloud-storage/document_storage_service/src/main.rs b/rust/cloud-storage/document_storage_service/src/main.rsindex 78189ba84f..7687a60140 100644--- a/rust/cloud-storage/document_storage_service/src/main.rs+++ b/rust/cloud-storage/document_storage_service/src/main.rs@@ -14,7 +14,7 @@ use channels::{use comms::{domain::service::ChannelServiceImpl,inbound::CommsRouterState,- outbound::{http::user_repo::UserRepoImpl, postgres::comms_repo::PgCommsRepo},+ outbound::postgres::{comms_repo::PgCommsRepo, user_repo::PgUserRepo},};use config::{Config, Environment};use connection_gateway_client::client::ConnectionGatewayClient;@@ -175,19 +175,6 @@ async fn main() -> anyhow::Result<()> {JwtValidationArgs::new_with_secret_manager(config.environment, &secretsmanager_client).await?;- let auth_service_secret_key = match config.environment {- Environment::Local => config- .vars- .authentication_service_secret_key- .as_ref()- .to_string(),- _ => secretsmanager_client- .get_secret_value(&config.vars.authentication_service_secret_key)- .await- .context("unable to get auth service secret")?- .to_string(),- };-// Initialize OpenSearch clientlet opensearch_password = match config.environment {Environment::Local => config.vars.opensearch_password.as_ref().to_string(),@@ -263,20 +250,14 @@ async fn main() -> anyhow::Result<()> {);// Create the ChannelServiceImpl - we need to create separate instances as it doesn't impl Clone- let auth_service_url: reqwest::Url = config- .vars- .authentication_service_url- .as_ref()- .parse()- .context("AUTHENTICATION_SERVICE_URL must be a valid url")?;let channel_service_for_soup = ChannelServiceImpl::new(PgCommsRepo { pool: db.clone() },- UserRepoImpl::new(auth_service_secret_key.clone(), auth_service_url.clone()),+ PgUserRepo::new(db.clone()),frecency_storage.clone(),);let channel_service_for_comms = ChannelServiceImpl::new(PgCommsRepo { pool: db.clone() },- UserRepoImpl::new(auth_service_secret_key, auth_service_url),+ PgUserRepo::new(db.clone()),frecency_storage.clone(),);