feat(search): align conversation identity search

This commit is contained in:
2026-06-07 08:05:12 +08:00
parent 9a7e455e1c
commit 450c8673d8
9 changed files with 171 additions and 42 deletions
+21 -2
View File
@@ -142,12 +142,13 @@ func timestampPtr(value *int64) int64 {
func ConversationDocument(conv model.Conversation) SearchDocument {
inboxID := conv.InboxID
content := conversationSearchContent(conv)
doc := SearchDocument{
ID: conv.ID,
Type: ResultTypeConversation,
AccountID: conv.AccountID,
Title: fmt.Sprintf("Conversation #%d", conv.ID),
Content: conv.Labels,
Title: conversationSearchTitle(conv),
Content: content,
Status: conv.Status,
Priority: conv.Priority,
Labels: splitLabels(conv.Labels),
@@ -165,6 +166,24 @@ func ConversationDocument(conv model.Conversation) SearchDocument {
return doc
}
func conversationSearchTitle(conv model.Conversation) string {
if conv.DisplayID != nil && *conv.DisplayID != 0 {
return fmt.Sprintf("Conversation #%d", *conv.DisplayID)
}
return fmt.Sprintf("Conversation #%d", conv.ID)
}
func conversationSearchContent(conv model.Conversation) string {
parts := make([]string, 0, 5)
if conv.DisplayID != nil && *conv.DisplayID != 0 {
parts = append(parts, fmt.Sprintf("%d", *conv.DisplayID))
}
if conv.Contact != nil {
parts = append(parts, conv.Contact.Name, conv.Contact.Email, conv.Contact.PhoneNumber, conv.Contact.Identifier)
}
return strings.TrimSpace(strings.Join(parts, " "))
}
func MessageDocument(msg model.Message) SearchDocument {
inboxID := msg.InboxID
conversationID := msg.ConversationID