MM-10036 Ensured correct handling of capitalized special mentions (#8607)
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
332411490d
Коммит
2d0fef4d94
@@ -842,15 +842,15 @@ func GetExplicitMentions(message string, keywords map[string][]string) *Explicit
|
||||
checkForMention := func(word string) bool {
|
||||
isMention := false
|
||||
|
||||
if word == "@here" {
|
||||
if strings.ToLower(word) == "@here" {
|
||||
ret.HereMentioned = true
|
||||
}
|
||||
|
||||
if word == "@channel" {
|
||||
if strings.ToLower(word) == "@channel" {
|
||||
ret.ChannelMentioned = true
|
||||
}
|
||||
|
||||
if word == "@all" {
|
||||
if strings.ToLower(word) == "@all" {
|
||||
ret.AllMentioned = true
|
||||
}
|
||||
|
||||
|
||||
@@ -186,6 +186,17 @@ func TestGetExplicitMentions(t *testing.T) {
|
||||
ChannelMentioned: true,
|
||||
},
|
||||
},
|
||||
"CapitalizedChannel": {
|
||||
Message: "this is an message for @cHaNNeL",
|
||||
Keywords: map[string][]string{"@channel": {id1, id2}},
|
||||
Expected: &ExplicitMentions{
|
||||
MentionedUserIds: map[string]bool{
|
||||
id1: true,
|
||||
id2: true,
|
||||
},
|
||||
ChannelMentioned: true,
|
||||
},
|
||||
},
|
||||
"All": {
|
||||
Message: "this is an message for @all",
|
||||
Keywords: map[string][]string{"@all": {id1, id2}},
|
||||
@@ -197,6 +208,17 @@ func TestGetExplicitMentions(t *testing.T) {
|
||||
AllMentioned: true,
|
||||
},
|
||||
},
|
||||
"CapitalizedAll": {
|
||||
Message: "this is an message for @ALL",
|
||||
Keywords: map[string][]string{"@all": {id1, id2}},
|
||||
Expected: &ExplicitMentions{
|
||||
MentionedUserIds: map[string]bool{
|
||||
id1: true,
|
||||
id2: true,
|
||||
},
|
||||
AllMentioned: true,
|
||||
},
|
||||
},
|
||||
"UserWithPeriod": {
|
||||
Message: "user.period doesn't complicate things at all by including periods in their username",
|
||||
Keywords: map[string][]string{"user.period": {id1}, "user": {id2}},
|
||||
@@ -439,6 +461,8 @@ func TestGetExplicitMentionsAtHere(t *testing.T) {
|
||||
"?@here?": true,
|
||||
"`@here`": false, // This case shouldn't mention since it's a code block
|
||||
"~@here~": true,
|
||||
"@HERE": true,
|
||||
"@hERe": true,
|
||||
}
|
||||
|
||||
for message, shouldMention := range cases {
|
||||
|
||||
Ссылка в новой задаче
Block a user