From 2337c580f670eb74564c92e99137c2917c714e37 Mon Sep 17 00:00:00 2001 From: Harshil Sharma <18575143+harshilsharma63@users.noreply.github.com> Date: Thu, 5 Jun 2025 10:05:25 +0530 Subject: [PATCH] Ignored email from client search (#31057) * Ignored email from client search * removed redundent email split --------- Co-authored-by: Mattermost Build --- .../mattermost-redux/src/utils/user_utils.test.ts | 14 +++++++------- .../mattermost-redux/src/utils/user_utils.ts | 7 +------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/webapp/channels/src/packages/mattermost-redux/src/utils/user_utils.test.ts b/webapp/channels/src/packages/mattermost-redux/src/utils/user_utils.test.ts index 92d07f9c4a..edd6351bd7 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/utils/user_utils.test.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/utils/user_utils.test.ts @@ -76,7 +76,7 @@ describe('user utils', () => { 'test.user', '.user', 'user', 'test', 'user name', 'test user name', 'tester', 'software engineer at mattermost', 'engineer at mattermost', 'at mattermost', 'mattermost', - 'test.user_name@example.com', 'example.com', + 'test.user_name', ]; expect(suggestions).toEqual(expectedSuggestions); }); @@ -181,12 +181,12 @@ describe('user utils', () => { expect(filterProfilesStartingWithTerm(users, 'left')).toEqual([userB]); }); - it('should match by email domain', () => { - expect(filterProfilesStartingWithTerm(users, 'right')).toEqual([userB]); + it('should not match by email domain as it is ignored', () => { + expect(filterProfilesStartingWithTerm(users, 'right')).not.toContain(userB); }); - it('should match by full email', () => { - expect(filterProfilesStartingWithTerm(users, 'left@right.com')).toEqual([userB]); + it('should not match by full email as email domain is ignored', () => { + expect(filterProfilesStartingWithTerm(users, 'left@right.com')).not.toContain(userB); }); it('should ignore leading @ for username', () => { @@ -264,11 +264,11 @@ describe('user utils', () => { }); it('should match by email domain', () => { - expect(filterProfilesMatchingWithTerm(users, 'right')).toEqual([userB]); + expect(filterProfilesMatchingWithTerm(users, 'right')).not.toContain(userB); }); it('should match by full email', () => { - expect(filterProfilesMatchingWithTerm(users, 'left@right.com')).toEqual([userB]); + expect(filterProfilesMatchingWithTerm(users, 'left@right.com')).not.toContain(userB); }); it('should ignore leading @ for username', () => { diff --git a/webapp/channels/src/packages/mattermost-redux/src/utils/user_utils.ts b/webapp/channels/src/packages/mattermost-redux/src/utils/user_utils.ts index 8a113e3358..d0a3173d88 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/utils/user_utils.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/utils/user_utils.ts @@ -160,13 +160,8 @@ export function nameSuggestionsForUser(user: UserProfile): string[] { profileSuggestions.push((user.nickname || '').toLowerCase()); const positionSuggestions = getSuggestionsSplitBy((user.position || '').toLowerCase(), ' '); profileSuggestions.push(...positionSuggestions); - const email = (user.email || '').toLowerCase(); + const email = (user.email || '').toLowerCase().split('@')[0]; profileSuggestions.push(email); - - const split = email.split('@'); - if (split.length > 1) { - profileSuggestions.push(split[1]); - } return profileSuggestions; }