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
add more enqueueing contacts messages (#3032)
Sean Ayebe76223dfcd6
diff --git a/rust/cloud-storage/comms_service/src/api/channels/add_participants.rs b/rust/cloud-storage/comms_service/src/api/channels/add_participants.rsindex 981400d73b..34cb5e07a1 100644--- a/rust/cloud-storage/comms_service/src/api/channels/add_participants.rs+++ b/rust/cloud-storage/comms_service/src/api/channels/add_participants.rs@@ -127,7 +127,9 @@ pub async fn handler(}).ok();- if matches!(channel_type, ChannelType::Private) && !channel_participants.is_empty() {+ if matches!(channel_type, ChannelType::Private | ChannelType::Team)+ && !channel_participants.is_empty()+ {// Contacts: add participants to social graphlet channel_participants: Vec<String> = channel_participants.iter()diff --git a/rust/cloud-storage/comms_service/src/api/channels/join_channel.rs b/rust/cloud-storage/comms_service/src/api/channels/join_channel.rsindex e3d943fb14..3f306c7fa7 100644--- a/rust/cloud-storage/comms_service/src/api/channels/join_channel.rs+++ b/rust/cloud-storage/comms_service/src/api/channels/join_channel.rs@@ -1,4 +1,7 @@-use crate::api::extractors::{ChannelId, ChannelTypeExtractor};+use std::collections::HashSet;++use crate::api::context::AppState;+use crate::api::extractors::{ChannelId, ChannelParticipants, ChannelTypeExtractor};use anyhow::Result;use axum::{extract::{Extension, State},@@ -6,9 +9,10 @@ use axum::{};use axum_extra::extract::Cached;use comms_db_client::participants::add_participant::{AddParticipantOptions, add_participant};+use contacts::domain::ports::ContactsIngress;+use macro_user_id::user_id::MacroUserIdStr;use model::comms::ParticipantRole;use model::user::UserContext;-use sqlx::PgPool;#[utoipa::path(post,@@ -27,12 +31,13 @@ use sqlx::PgPool;))]#[tracing::instrument(- skip(db),+ skip(ctx),fields(user_id=?user_ctx.user_id))]pub async fn join_channel_handler(- State(db): State<PgPool>,+ State(ctx): State<AppState>,Cached(ChannelTypeExtractor(channel_type)): Cached<ChannelTypeExtractor>,+ Cached(ChannelParticipants(channel_participants)): Cached<ChannelParticipants>,Cached(ChannelId(channel_id)): Cached<ChannelId>,user_ctx: Extension<UserContext>,) -> Result<StatusCode, (StatusCode, String)> {@@ -45,7 +50,7 @@ pub async fn join_channel_handler(}add_participant(- &db,+ &ctx.db,AddParticipantOptions {channel_id: &channel_id,user_id: &user_ctx.user_id,@@ -61,5 +66,36 @@ pub async fn join_channel_handler()})?;+ if !matches!(+ channel_type,+ models_comms::channel::ChannelType::DirectMessage+ | models_comms::channel::ChannelType::Organization+ ) && !channel_participants.is_empty()+ {+ let joiner = MacroUserIdStr::try_from(user_ctx.user_id.clone()).map_err(|e| {+ tracing::error!(error=?e, "invalid user id for contacts");+ (StatusCode::BAD_REQUEST, "invalid user id".to_string())+ })?;++ let mut contacts_users: HashSet<MacroUserIdStr<'static>> = channel_participants+ .iter()+ .map(|p| p.user_id.to_string())+ .map(MacroUserIdStr::try_from)+ .collect::<Result<_, _>>()+ .map_err(|e| {+ tracing::error!(error=?e, "invalid user id for contacts");+ (StatusCode::BAD_REQUEST, "invalid user id".to_string())+ })?;+ contacts_users.insert(joiner);++ ctx.contacts_ingress+ .enqueue_contacts(contacts_users)+ .await+ .inspect_err(|e| {+ tracing::error!(error=?e, "unable to create 'join channel' contacts message");+ })+ .ok();+ }+Ok(StatusCode::OK)}