diff options
author | Harrison Healey <harrisonmhealey@gmail.com> | 2018-04-11 10:33:20 -0400 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2018-04-11 10:33:20 -0400 |
commit | 2d0fef4d943198014913069d2b79a73f2e3a7d9a (patch) | |
tree | 5d7031dd6449e679cd9447c03d86372e182507c8 | |
parent | 332411490ded04b66d3cf843a4f31ba64aeb6d6f (diff) | |
download | chat-2d0fef4d943198014913069d2b79a73f2e3a7d9a.tar.gz chat-2d0fef4d943198014913069d2b79a73f2e3a7d9a.tar.bz2 chat-2d0fef4d943198014913069d2b79a73f2e3a7d9a.zip |
MM-10036 Ensured correct handling of capitalized special mentions (#8607)
-rw-r--r-- | app/notification.go | 6 | ||||
-rw-r--r-- | app/notification_test.go | 24 |
2 files changed, 27 insertions, 3 deletions
diff --git a/app/notification.go b/app/notification.go index 5b7ed5ad2..06c1c19bc 100644 --- a/app/notification.go +++ b/app/notification.go @@ -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 } diff --git a/app/notification_test.go b/app/notification_test.go index 1abdd3d61..8df19e2bf 100644 --- a/app/notification_test.go +++ b/app/notification_test.go @@ -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 { |