From 1756033d5fbdea6b8c80b1988683590cffa407f9 Mon Sep 17 00:00:00 2001 From: Yevhen Shevchuk Date: Wed, 9 Sep 2026 10:54:44 +0300 Subject: [PATCH] fix(quick_reply): substring search without requiring '*' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Quick reply search matched only when the caller supplied a '*' wildcard, because the shared q handling merely maps '*' -> '%'. A bare term like "мо" became ILIKE 'мо' (exact match) and returned nothing. Wrap the q term in '%...%' for both Quick reply query paths (GetAllPage and GetAllPageByAgentPriority) so it matches a substring anywhere in the name/text by default. The wrapping is local to Quick reply and preserves nil-when-empty so the ":Q isnull" guard still disables the filter. WTEL-10364 --- store/sqlstore/cc_quick_reply_store.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/store/sqlstore/cc_quick_reply_store.go b/store/sqlstore/cc_quick_reply_store.go index dab306a3..3506bf66 100644 --- a/store/sqlstore/cc_quick_reply_store.go +++ b/store/sqlstore/cc_quick_reply_store.go @@ -20,6 +20,14 @@ func NewSqlQuickReplyStore(sqlStore SqlStore) store.QuickReplyStore { return us } +func quickReplySearchPattern(q *string) *string { + if q == nil { + return nil + } + + return model.NewString("%" + *q + "%") +} + func (s SqlQuickReplyStore) Create(ctx context.Context, domainId int64, reply *model.QuickReply) (*model.QuickReply, model.AppError) { var resp *model.QuickReply @@ -71,7 +79,7 @@ func (s SqlQuickReplyStore) Create(ctx context.Context, domainId int64, reply *m func (s SqlQuickReplyStore) GetAllPage(ctx context.Context, domainId int64, search *model.SearchQuickReply, userId int64) ([]*model.QuickReply, model.AppError) { args := map[string]any{ "DomainId": domainId, - "Q": search.GetQ(), + "Q": quickReplySearchPattern(search.GetQ()), "Ids": pq.Array(search.Ids), "Name": search.Name, "UserId": userId, @@ -111,7 +119,7 @@ func (s SqlQuickReplyStore) GetAllPageByAgentPriority(ctx context.Context, domai args := map[string]any { "DomainId": domainId, "UserId": userId, - "Q": search.GetQ(), + "Q": quickReplySearchPattern(search.GetQ()), "Ids": pq.Array(search.Ids), "Name": search.Name, "Queue": pq.Array(search.Queue),