Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

chore(comms_service): add back channel name processing for names index (#310)

Will Hutchinson581745f44ec6
diff --git a/rust/cloud-storage/comms_service/src/api/channels/create_channel.rs b/rust/cloud-storage/comms_service/src/api/channels/create_channel.rs
index aefd69d40f..98fcf2887d 100644
--- a/rust/cloud-storage/comms_service/src/api/channels/create_channel.rs
+++ b/rust/cloud-storage/comms_service/src/api/channels/create_channel.rs
@@ -8,7 +8,10 @@ use axum::{
use comms_db_client::channels::create_channel::{CreateChannelOptions, create_channel};
use model::comms::ChannelType;
use model::user::UserContext;
+use models_opensearch::SearchEntityType;
use serde::{Deserialize, Serialize};
+use sqs_client::search::{SearchQueueMessage, name::UpdateEntityName};
+use tracing::Instrument;
use utoipa::ToSchema;
#[derive(Debug, Serialize, Deserialize, ToSchema)]
@@ -111,6 +114,29 @@ pub async fn create_channel_handler(
})?;
}
+ if req.name.is_some() {
+ tokio::spawn({
+ let sqs_client = ctx.sqs_client.clone();
+ let channel_id = id;
+ async move {
+ tracing::trace!("sending message to search extractor queue");
+
+ let _ = sqs_client
+ .send_message_to_search_event_queue(SearchQueueMessage::UpdateEntityName(
+ UpdateEntityName {
+ entity_id: channel_id,
+ entity_type: SearchEntityType::Channels,
+ },
+ ))
+ .await
+ .inspect_err(|e| {
+ tracing::error!(error=?e, "SEARCH_QUEUE unable to enqueue message");
+ });
+ }
+ .in_current_span()
+ });
+ }
+
Ok((
StatusCode::OK,
Json(CreateChannelResponse { id: id.to_string() }),
diff --git a/rust/cloud-storage/comms_service/src/api/channels/patch_channel.rs b/rust/cloud-storage/comms_service/src/api/channels/patch_channel.rs
index fc4658455c..a7f55de2f3 100644
--- a/rust/cloud-storage/comms_service/src/api/channels/patch_channel.rs
+++ b/rust/cloud-storage/comms_service/src/api/channels/patch_channel.rs
@@ -7,6 +7,8 @@ use axum::{Json, extract::State, http::StatusCode};
use axum_extra::extract::Cached;
use comms_db_client::channels::patch_channel::{self, PatchChannelOptions};
use model::comms::ChannelType;
+use models_opensearch::SearchEntityType;
+use tracing::Instrument;
#[utoipa::path(
patch,
@@ -36,6 +38,8 @@ pub async fn patch_channel_handler(
));
}
+ let name = req.channel_name.clone();
+
patch_channel::patch_channel(&ctx.db, &channel_id, &channel_owner.context.user_id, req)
.await
.map_err(|e| {
@@ -47,5 +51,30 @@ pub async fn patch_channel_handler(
)
})?;
+ if name.is_some() {
+ tokio::spawn({
+ let sqs_client = ctx.sqs_client.clone();
+ let channel_id = channel_id;
+ async move {
+ tracing::trace!("sending message to search extractor queue");
+
+ let _ = sqs_client
+ .send_message_to_search_event_queue(
+ sqs_client::search::SearchQueueMessage::UpdateEntityName(
+ sqs_client::search::name::UpdateEntityName {
+ entity_id: channel_id,
+ entity_type: SearchEntityType::Channels,
+ },
+ ),
+ )
+ .await
+ .inspect_err(|e| {
+ tracing::error!(error=?e, "SEARCH_QUEUE unable to enqueue message");
+ });
+ }
+ .in_current_span()
+ });
+ }
+
Ok((StatusCode::OK, "patched channel".to_string()))
}
diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-34a1c3b64fdb985b5e78d815f8fac33efbd25ad5cb6854e9fe3949518f530570.json b/rust/cloud-storage/macro_db_client/.sqlx/query-34a1c3b64fdb985b5e78d815f8fac33efbd25ad5cb6854e9fe3949518f530570.json
new file mode 100644
index 0000000000..32c5fe0adb
--- /dev/null
+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-34a1c3b64fdb985b5e78d815f8fac33efbd25ad5cb6854e9fe3949518f530570.json
@@ -0,0 +1,22 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT\n c.name as \"name?\"\n FROM\n \"comms_channels\" c\n WHERE\n c.id = $1\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "name?",
+ "type_info": "Varchar"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Uuid"
+ ]
+ },
+ "nullable": [
+ true
+ ]
+ },
+ "hash": "34a1c3b64fdb985b5e78d815f8fac33efbd25ad5cb6854e9fe3949518f530570"
+}
diff --git a/rust/cloud-storage/macro_db_client/src/entity_name.rs b/rust/cloud-storage/macro_db_client/src/entity_name.rs
index 0543f12d49..21e9404cd9 100644
--- a/rust/cloud-storage/macro_db_client/src/entity_name.rs
+++ b/rust/cloud-storage/macro_db_client/src/entity_name.rs
@@ -57,6 +57,22 @@ pub async fn get_entity_name(
.fetch_one(db)
.await?
}
+ SearchEntityType::Channels => {
+ sqlx::query!(
+ r#"
+ SELECT
+ c.name as "name?"
+ FROM
+ "comms_channels" c
+ WHERE
+ c.id = $1
+ "#,
+ entity_id,
+ )
+ .map(|row| row.name)
+ .fetch_one(db)
+ .await?
+ }
_ => {
anyhow::bail!("entity type not supported");
}