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(sps): delete email link for SPS entity names (#431)
Will Hutchinsonbf5705633e2a
diff --git a/rust/cloud-storage/opensearch_client/src/delete/name.rs b/rust/cloud-storage/opensearch_client/src/delete/name.rsindex d378794bda..a337e69b42 100644--- a/rust/cloud-storage/opensearch_client/src/delete/name.rs+++ b/rust/cloud-storage/opensearch_client/src/delete/name.rs@@ -113,3 +113,43 @@ pub async fn delete_entity_name_bulk_for_user(Ok(())}++/// Deletes all names for a specified user_id and entity_type+#[tracing::instrument(skip(client), err)]+pub async fn delete_entity_name_bulk_for_user_by_entity_type(+ client: &opensearch::OpenSearch,+ user_id: &str,+ entity_type: &SearchEntityType,+) -> Result<()> {+ let query = serde_json::json!({+ "query": {+ "bool": {+ "must": [+ {+ "term": {+ "user_id": user_id+ }+ },+ {+ "term": {+ "entity_type": entity_type.as_ref()+ }+ }+ ]+ }+ }+ });++ client+ .delete_by_query(opensearch::DeleteByQueryParts::Index(&[+ SearchIndex::Names.as_ref()+ ]))+ .body(query)+ .refresh(true) // Ensure the index reflects changes immediately+ .send()+ .await+ .map_client_error()+ .await?;++ Ok(())+}diff --git a/rust/cloud-storage/opensearch_client/src/name.rs b/rust/cloud-storage/opensearch_client/src/name.rsindex e216e3c9f3..69b7132128 100644--- a/rust/cloud-storage/opensearch_client/src/name.rs+++ b/rust/cloud-storage/opensearch_client/src/name.rs@@ -2,7 +2,10 @@ use models_opensearch::SearchEntityType;use crate::{OpensearchClient, Result,- delete::name::{delete_entity_name, delete_entity_name_bulk, delete_entity_name_bulk_for_user},+ delete::name::{+ delete_entity_name, delete_entity_name_bulk, delete_entity_name_bulk_for_user,+ delete_entity_name_bulk_for_user_by_entity_type,+ },upsert::name::{UpsertEntityNameArgs, upsert_entity_name},};@@ -38,4 +41,14 @@ impl OpensearchClient {pub async fn delete_entities_for_user(&self, user_id: &str) -> Result<()> {delete_entity_name_bulk_for_user(&self.inner, user_id).await}++ /// Delete entity names for a user+ #[tracing::instrument(skip(self), err)]+ pub async fn delete_entities_for_user_by_entity_type(+ &self,+ user_id: &str,+ entity_type: &SearchEntityType,+ ) -> Result<()> {+ delete_entity_name_bulk_for_user_by_entity_type(&self.inner, user_id, entity_type).await+ }}diff --git a/rust/cloud-storage/search_processing_service/src/process/email/remove.rs b/rust/cloud-storage/search_processing_service/src/process/email/remove.rsindex 48c8b74fe7..8df0825449 100644--- a/rust/cloud-storage/search_processing_service/src/process/email/remove.rs+++ b/rust/cloud-storage/search_processing_service/src/process/email/remove.rs@@ -1,3 +1,4 @@+use models_opensearch::SearchEntityType;use opensearch_client::OpensearchClient;use sqs_client::search::email::{EmailLinkMessage, EmailMessage};@@ -21,7 +22,10 @@ pub async fn process_remove_messages_by_link_id(.await?;opensearch_client- .delete_entities_for_user(remove_link_message.macro_user_id.as_str())+ .delete_entities_for_user_by_entity_type(+ remove_link_message.macro_user_id.as_str(),+ &SearchEntityType::Emails,+ ).await?;Ok(())