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.

fix(search): normalize mention filter format between soup and OpenSearch (#2518)

gbirmana09e3ede568d
diff --git a/js/app/packages/app/component/next-soup/soup-view/create-search-state.ts b/js/app/packages/app/component/next-soup/soup-view/create-search-state.ts
index 1dc78a07ca..043ec67748 100644
--- a/js/app/packages/app/component/next-soup/soup-view/create-search-state.ts
+++ b/js/app/packages/app/component/next-soup/soup-view/create-search-state.ts
@@ -82,7 +82,7 @@ export const createSearchState = ({
...filters,
channel_filters: {
...filters.channel_filters,
- mentions: mentionIds.map((id) => `user:${id}`),
+ mentions: mentionIds,
},
}
: filters,
diff --git a/rust/cloud-storage/comms_db_client/src/messages/get_channel_message.rs b/rust/cloud-storage/comms_db_client/src/messages/get_channel_message.rs
index b04896cab7..e551c431e1 100644
--- a/rust/cloud-storage/comms_db_client/src/messages/get_channel_message.rs
+++ b/rust/cloud-storage/comms_db_client/src/messages/get_channel_message.rs
@@ -1,3 +1,4 @@
+use crate::model::SimpleMention;
use model::comms::{ChannelMessage, ChannelType, GetChannelMessageResponse};
use uuid::Uuid;
@@ -36,7 +37,13 @@ pub async fn get_channel_message_by_id(
"#,
&message_id.to_string(),
)
- .map(|row| format!("{}:{}", row.entity_type, row.entity_id))
+ .map(|row| {
+ SimpleMention {
+ entity_type: row.entity_type,
+ entity_id: row.entity_id,
+ }
+ .to_string()
+ })
.fetch_all(db)
.await?;
diff --git a/rust/cloud-storage/comms_db_client/src/model/mod.rs b/rust/cloud-storage/comms_db_client/src/model/mod.rs
index 22ef908768..5a107e4924 100644
--- a/rust/cloud-storage/comms_db_client/src/model/mod.rs
+++ b/rust/cloud-storage/comms_db_client/src/model/mod.rs
@@ -1,6 +1,7 @@
use macro_user_id::user_id::MacroUserIdStr;
use model::comms::ChannelType;
use serde::{Deserialize, Serialize};
+use std::fmt;
use utoipa::ToSchema;
use uuid::Uuid;
@@ -59,6 +60,12 @@ pub struct SimpleMention {
pub entity_id: String,
}
+impl fmt::Display for SimpleMention {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ write!(f, "{}:{}", self.entity_type, self.entity_id)
+ }
+}
+
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct MessageMention {
pub message_id: Uuid,
diff --git a/rust/cloud-storage/search_service/src/api/search/simple/filter.rs b/rust/cloud-storage/search_service/src/api/search/simple/filter.rs
index 158ca1039f..89a6298dce 100644
--- a/rust/cloud-storage/search_service/src/api/search/simple/filter.rs
+++ b/rust/cloud-storage/search_service/src/api/search/simple/filter.rs
@@ -1,6 +1,7 @@
//! This module is responsible for defining a trait to convert item_filters into a UnifiedSearchArgsVariant
//! This is used in simple_unified.rs
+use comms_db_client::model::SimpleMention;
use opensearch_client::search::unified::{
UnifiedChannelMessageSearchArgs, UnifiedChatSearchArgs, UnifiedDocumentSearchArgs,
UnifiedEmailSearchArgs,
@@ -81,7 +82,17 @@ impl FilterVariantToSearchArgs for item_filters::ChannelFilters {
.map(|c| c.to_string())
.collect(),
thread_ids: self.thread_ids.clone(),
- mentions: self.mentions.clone(),
+ mentions: self
+ .mentions
+ .iter()
+ .map(|m| {
+ SimpleMention {
+ entity_type: "user".to_string(),
+ entity_id: m.clone(),
+ }
+ .to_string()
+ })
+ .collect(),
sender_ids: self.sender_ids.clone(),
..Default::default()
})