[PLT-7701] Fix emoji names that trigger mention (#7663)

* fix emoji names that trigger mention

* remove regex and rearrange based on comment

* make ":@here:" to not trigger a mention
Этот коммит содержится в:
Saturnino Abril
2017-10-25 22:11:20 +08:00
коммит произвёл GitHub
родитель 1d968eb55e
Коммит f632232862
2 изменённых файлов: 34 добавлений и 5 удалений

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

@@ -200,6 +200,30 @@ func TestGetExplicitMentions(t *testing.T) {
if mentions, _, _, _, _ := GetExplicitMentions(message, keywords); len(mentions) != 1 || !mentions[id1] || mentions[id2] || mentions[id3] {
t.Fatal("should've only mentioned aaa")
}
message = ":smile:"
keywords = map[string][]string{"smile": {id1}, "smiley": {id2}, "smiley_cat": {id3}}
if mentions, _, _, _, _ := GetExplicitMentions(message, keywords); len(mentions) == 1 || mentions[id1] {
t.Fatal("should not mentioned smile")
}
message = "smile"
keywords = map[string][]string{"smile": {id1}, "smiley": {id2}, "smiley_cat": {id3}}
if mentions, _, _, _, _ := GetExplicitMentions(message, keywords); len(mentions) != 1 || !mentions[id1] || mentions[id2] || mentions[id3] {
t.Fatal("should've only mentioned smile")
}
message = ":smile"
keywords = map[string][]string{"smile": {id1}, "smiley": {id2}, "smiley_cat": {id3}}
if mentions, _, _, _, _ := GetExplicitMentions(message, keywords); len(mentions) != 1 || !mentions[id1] || mentions[id2] || mentions[id3] {
t.Fatal("should've only mentioned smile")
}
message = "smile:"
keywords = map[string][]string{"smile": {id1}, "smiley": {id2}, "smiley_cat": {id3}}
if mentions, _, _, _, _ := GetExplicitMentions(message, keywords); len(mentions) != 1 || !mentions[id1] || mentions[id2] || mentions[id3] {
t.Fatal("should've only mentioned smile")
}
}
func TestGetExplicitMentionsAtHere(t *testing.T) {
@@ -230,7 +254,7 @@ func TestGetExplicitMentionsAtHere(t *testing.T) {
"\\@here\\": true,
"|@here|": true,
";@here;": true,
":@here:": true,
":@here:": false, // This case shouldn't trigger a mention since it follows the format of reactions e.g. :word:
"'@here'": true,
"\"@here\"": true,
",@here,": true,