Ignored email from client search (#31057)

* Ignored email from client search

* removed redundent email split

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Harshil Sharma
2025-06-05 10:05:25 +05:30
коммит произвёл GitHub
родитель 91862811f5
Коммит 2337c580f6
2 изменённых файлов: 8 добавлений и 13 удалений

Просмотреть файл

@@ -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', () => {

Просмотреть файл

@@ -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;
}