Skip to content

Commit

Permalink
do not use regex on email and phone fields search
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusbsilva137 committed Dec 4, 2024
1 parent 1e5b28f commit 5476698
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions apps/meteor/server/models/raw/LivechatContacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ export class LivechatContactsRaw extends BaseRaw<ILivechatContact> implements IL
): FindPaginated<FindCursor<ILivechatContact>> {
const { searchText, unknown = false, email, phone } = search;
const searchRegex = escapeRegExp(searchText || '');
const emailRegex = escapeRegExp(email || searchText || '');
const phoneRegex = escapeRegExp(phone || searchText || '');
const match: Filter<ILivechatContact & RootFilterOperators<ILivechatContact>> = {
...(searchText && {
$or: [
Expand All @@ -120,8 +118,8 @@ export class LivechatContactsRaw extends BaseRaw<ILivechatContact> implements IL
{ 'phones.phoneNumber': { $regex: searchRegex, $options: 'i' } },
],
}),
...(email && { 'emails.address': { $regex: emailRegex, $options: 'i' } }),
...(phone && { 'phones.phoneNumber': { $regex: phoneRegex, $options: 'i' } }),
...(email && { 'emails.address': email }),
...(phone && { 'phones.phoneNumber': phone }),
unknown,
};

Expand Down

0 comments on commit 5476698

Please sign in to comment.