summaryrefslogtreecommitdiffstats
path: root/app/notification.go
diff options
context:
space:
mode:
authorSaturnino Abril <saturnino.abril@gmail.com>2017-10-25 22:11:20 +0800
committerGitHub <noreply@github.com>2017-10-25 22:11:20 +0800
commitf63223286295a1261c950c482701b99963fb260c (patch)
treebfb56efaf64ef16047b6996733b719d27c71fe05 /app/notification.go
parent1d968eb55eae7f0f6db087c9e8466b11800b888a (diff)
downloadchat-f63223286295a1261c950c482701b99963fb260c.tar.gz
chat-f63223286295a1261c950c482701b99963fb260c.tar.bz2
chat-f63223286295a1261c950c482701b99963fb260c.zip
[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
Diffstat (limited to 'app/notification.go')
-rw-r--r--app/notification.go13
1 files changed, 9 insertions, 4 deletions
diff --git a/app/notification.go b/app/notification.go
index bbd305b05..3adf14419 100644
--- a/app/notification.go
+++ b/app/notification.go
@@ -804,11 +804,16 @@ func GetExplicitMentions(message string, keywords map[string][]string) (map[stri
message = removeCodeFromMessage(message)
for _, word := range strings.FieldsFunc(message, func(c rune) bool {
- // Split on any whitespace or punctuation that can't be part of an at mention
- return !(c == '.' || c == '-' || c == '_' || c == '@' || unicode.IsLetter(c) || unicode.IsNumber(c))
+ // Split on any whitespace or punctuation that can't be part of an at mention or emoji pattern
+ return !(c == ':' || c == '.' || c == '-' || c == '_' || c == '@' || unicode.IsLetter(c) || unicode.IsNumber(c))
}) {
isMention := false
+ // skip word with format ':word:' with an assumption that it is an emoji format only
+ if word[0] == ':' && word[len(word)-1] == ':' {
+ continue
+ }
+
if word == "@here" {
hereMentioned = true
}
@@ -837,10 +842,10 @@ func GetExplicitMentions(message string, keywords map[string][]string) (map[stri
continue
}
- if strings.ContainsAny(word, ".-") {
+ if strings.ContainsAny(word, ".-:") {
// This word contains a character that may be the end of a sentence, so split further
splitWords := strings.FieldsFunc(word, func(c rune) bool {
- return c == '.' || c == '-'
+ return c == '.' || c == '-' || c == ':'
})
for _, splitWord := range splitWords {