summaryrefslogtreecommitdiffstats
path: root/app/notification.go
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2017-04-28 10:13:07 -0400
committerChristopher Speller <crspeller@gmail.com>2017-04-28 10:13:07 -0400
commitc3e17da8c8ebd101d43ea9185821c44b651535b1 (patch)
tree48888cd816faa1beb6c822cc60c095bc6e6b232c /app/notification.go
parent83bfd95f65f5e74402f7146feecb68b37dd0bf84 (diff)
downloadchat-c3e17da8c8ebd101d43ea9185821c44b651535b1.tar.gz
chat-c3e17da8c8ebd101d43ea9185821c44b651535b1.tar.bz2
chat-c3e17da8c8ebd101d43ea9185821c44b651535b1.zip
PLT-6271 Changed word splitting to initially split on any non-name character (#6261)
* PLT-6271 Changed word splitting to initially split on any non-name character * Fixed detection of out of channel mentions
Diffstat (limited to 'app/notification.go')
-rw-r--r--app/notification.go18
1 files changed, 12 insertions, 6 deletions
diff --git a/app/notification.go b/app/notification.go
index c14701b5f..c48465003 100644
--- a/app/notification.go
+++ b/app/notification.go
@@ -665,8 +665,8 @@ 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 whitespace (as strings.Fields normally does) or on Markdown characters
- return unicode.IsSpace(c) || c == '*' || c == '~'
+ // 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))
}) {
isMention := false
@@ -694,11 +694,14 @@ func GetExplicitMentions(message string, keywords map[string][]string) (map[stri
isMention = true
}
- if !isMention {
- // No matches were found with the string split just on whitespace so try further splitting
- // the message on punctuation
+ if isMention {
+ continue
+ }
+
+ 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 model.SplitRunes[c]
+ return c == '.' || c == '-'
})
for _, splitWord := range splitWords {
@@ -727,6 +730,9 @@ func GetExplicitMentions(message string, keywords map[string][]string) (map[stri
potentialOthersMentioned = append(potentialOthersMentioned, username)
}
}
+ } else if _, ok := systemMentions[word]; !ok && strings.HasPrefix(word, "@") {
+ username := word[1:]
+ potentialOthersMentioned = append(potentialOthersMentioned, username)
}
}