summaryrefslogtreecommitdiffstats
path: root/app/notification.go
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2018-06-05 13:34:21 -0400
committerCarlos Tadeu Panato Junior <ctadeu@gmail.com>2018-06-05 19:34:21 +0200
commitbca7339e4ccb410a1aa048842074af9518198b9e (patch)
tree86b7e4991816764a9af73452c7a2c8d027d26b7a /app/notification.go
parent5e36cbae09082d830ea4beb4f3049243d23121a1 (diff)
downloadchat-bca7339e4ccb410a1aa048842074af9518198b9e.tar.gz
chat-bca7339e4ccb410a1aa048842074af9518198b9e.tar.bz2
chat-bca7339e4ccb410a1aa048842074af9518198b9e.zip
MM-10597 Improved handling of punctuation around notifications (#8901)
Diffstat (limited to 'app/notification.go')
-rw-r--r--app/notification.go21
1 files changed, 11 insertions, 10 deletions
diff --git a/app/notification.go b/app/notification.go
index 401675f4e..741dadd9a 100644
--- a/app/notification.go
+++ b/app/notification.go
@@ -1004,23 +1004,24 @@ func GetExplicitMentions(message string, keywords map[string][]string) *Explicit
continue
}
+ word = strings.TrimLeft(word, ":.-_")
+
if checkForMention(word) {
continue
}
- // remove trailing '.', as that is the end of a sentence
- foundWithSuffix := false
- for _, suffixPunctuation := range []string{".", ":"} {
- for strings.HasSuffix(word, suffixPunctuation) {
- word = strings.TrimSuffix(word, suffixPunctuation)
- if checkForMention(word) {
- foundWithSuffix = true
- break
- }
+ foundWithoutSuffix := false
+ wordWithoutSuffix := word
+ for strings.LastIndexAny(wordWithoutSuffix, ".-:_") != -1 {
+ wordWithoutSuffix = wordWithoutSuffix[0 : len(wordWithoutSuffix)-1]
+
+ if checkForMention(wordWithoutSuffix) {
+ foundWithoutSuffix = true
+ break
}
}
- if foundWithSuffix {
+ if foundWithoutSuffix {
continue
}