[MM-28447] Avoid "ghost mentions" when "First Name" is not set, but "First Name trigger mention" setting is set (#15577)
* Do not add any keyword regarding first name if the first name is not set * Add test Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
c392f993d6
Коммит
9449d0e302
@@ -873,7 +873,7 @@ func addMentionKeywordsForUser(keywords map[string][]string, profile *model.User
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If turned on, add the user's case sensitive first name
|
// If turned on, add the user's case sensitive first name
|
||||||
if profile.NotifyProps[model.FIRST_NAME_NOTIFY_PROP] == "true" {
|
if profile.NotifyProps[model.FIRST_NAME_NOTIFY_PROP] == "true" && profile.FirstName != "" {
|
||||||
keywords[profile.FirstName] = append(keywords[profile.FirstName], profile.Id)
|
keywords[profile.FirstName] = append(keywords[profile.FirstName], profile.Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1424,6 +1424,24 @@ func TestAddMentionKeywordsForUser(t *testing.T) {
|
|||||||
assert.NotContains(t, keywords["Robert"], user.Id)
|
assert.NotContains(t, keywords["Robert"], user.Id)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("should not add case sensitive first name if enabled but empty First Name", func(t *testing.T) {
|
||||||
|
user := &model.User{
|
||||||
|
Id: model.NewId(),
|
||||||
|
Username: "user",
|
||||||
|
FirstName: "",
|
||||||
|
LastName: "Robert",
|
||||||
|
NotifyProps: map[string]string{
|
||||||
|
model.FIRST_NAME_NOTIFY_PROP: "true",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
channelNotifyProps := map[string]string{}
|
||||||
|
|
||||||
|
keywords := map[string][]string{}
|
||||||
|
addMentionKeywordsForUser(keywords, user, channelNotifyProps, nil, false)
|
||||||
|
|
||||||
|
assert.NotContains(t, keywords[""], user.Id)
|
||||||
|
})
|
||||||
|
|
||||||
t.Run("should not add case sensitive first name if disabled", func(t *testing.T) {
|
t.Run("should not add case sensitive first name if disabled", func(t *testing.T) {
|
||||||
user := &model.User{
|
user := &model.User{
|
||||||
Id: model.NewId(),
|
Id: model.NewId(),
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user