From ac8e1fe97ed83d2fda23490cfd2ffcf4b42e4f42 Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Fri, 19 Jun 2015 08:08:54 -0400 Subject: fix a bug where mentions wouldn't update for words after a new line --- api/post.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/post.go b/api/post.go index 36607c231..f8125a442 100644 --- a/api/post.go +++ b/api/post.go @@ -302,10 +302,11 @@ func fireAndForgetNotifications(post *model.Post, teamId, teamUrl string) { // Build a map as a list of unique user_ids that are mentioned in this post splitF := func(c rune) bool { - return c == ',' || c == ' ' || c == '.' || c == '!' || c == '?' || c == ':' || c == '<' || c == '>' + return c == ',' || c == ' ' || c == '.' || c == '!' || c == '?' || c == ':' || c == '<' || c == '>' || c == '\n' } splitMessage := strings.FieldsFunc(strings.Replace(post.Message, "
", " ", -1), splitF) for _, word := range splitMessage { + l4g.Debug(word) // Non-case-sensitive check for regular keys userIds1, keyMatch := keywordMap[strings.ToLower(word)] -- cgit v1.2.3-1-g7c22 From 6051b01cdfbf426a6d069aa57cb612c1813a8c3f Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Fri, 19 Jun 2015 08:09:35 -0400 Subject: remove logging --- api/post.go | 1 - 1 file changed, 1 deletion(-) diff --git a/api/post.go b/api/post.go index f8125a442..0e521034d 100644 --- a/api/post.go +++ b/api/post.go @@ -306,7 +306,6 @@ func fireAndForgetNotifications(post *model.Post, teamId, teamUrl string) { } splitMessage := strings.FieldsFunc(strings.Replace(post.Message, "
", " ", -1), splitF) for _, word := range splitMessage { - l4g.Debug(word) // Non-case-sensitive check for regular keys userIds1, keyMatch := keywordMap[strings.ToLower(word)] -- cgit v1.2.3-1-g7c22 From 09c4089c95ed8f4306f0005918677bdbaa18a486 Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Fri, 19 Jun 2015 08:25:47 -0400 Subject: improved split function --- api/post.go | 2 +- model/utils.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/api/post.go b/api/post.go index 0e521034d..3acc95551 100644 --- a/api/post.go +++ b/api/post.go @@ -302,7 +302,7 @@ func fireAndForgetNotifications(post *model.Post, teamId, teamUrl string) { // Build a map as a list of unique user_ids that are mentioned in this post splitF := func(c rune) bool { - return c == ',' || c == ' ' || c == '.' || c == '!' || c == '?' || c == ':' || c == '<' || c == '>' || c == '\n' + return model.SplitRunes[c] } splitMessage := strings.FieldsFunc(strings.Replace(post.Message, "
", " ", -1), splitF) for _, word := range splitMessage { diff --git a/model/utils.go b/model/utils.go index 2541247de..9f1788699 100644 --- a/model/utils.go +++ b/model/utils.go @@ -319,3 +319,5 @@ func ClearMentionTags(post string) string { var UrlRegex = regexp.MustCompile(`^((?:[a-z]+:\/\/)?(?:(?:[a-z0-9\-]+\.)+(?:[a-z]{2}|aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel|local|internal))(:[0-9]{1,5})?(?:\/[a-z0-9_\-\.~]+)*(\/([a-z0-9_\-\.]*)(?:\?[a-z0-9+_~\-\.%=&]*)?)?(?:#[a-zA-Z0-9!$&'()*+.=-_~:@/?]*)?)(?:\s+|$)$`) var PartialUrlRegex = regexp.MustCompile(`/api/v1/files/(get|get_image)/([A-Za-z0-9]{26})/([A-Za-z0-9]{26})/(([A-Za-z0-9]+/)?.+\.[A-Za-z0-9]{3,})`) + +var SplitRunes = map[rune]bool{',': true, ' ': true, '.': true, '!': true, '?': true, ':': true, ';': true, '\n': true, '<': true, '>': true, '(': true, ')': true, '{': true, '}': true, '[': true, ']': true, '+': true} -- cgit v1.2.3-1-g7c22 From 5aef020ca2684a816fce8bc22b0b53ffd594756c Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Fri, 19 Jun 2015 08:30:16 -0400 Subject: added slashes to split map --- model/utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/utils.go b/model/utils.go index 9f1788699..262bda319 100644 --- a/model/utils.go +++ b/model/utils.go @@ -320,4 +320,4 @@ func ClearMentionTags(post string) string { var UrlRegex = regexp.MustCompile(`^((?:[a-z]+:\/\/)?(?:(?:[a-z0-9\-]+\.)+(?:[a-z]{2}|aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel|local|internal))(:[0-9]{1,5})?(?:\/[a-z0-9_\-\.~]+)*(\/([a-z0-9_\-\.]*)(?:\?[a-z0-9+_~\-\.%=&]*)?)?(?:#[a-zA-Z0-9!$&'()*+.=-_~:@/?]*)?)(?:\s+|$)$`) var PartialUrlRegex = regexp.MustCompile(`/api/v1/files/(get|get_image)/([A-Za-z0-9]{26})/([A-Za-z0-9]{26})/(([A-Za-z0-9]+/)?.+\.[A-Za-z0-9]{3,})`) -var SplitRunes = map[rune]bool{',': true, ' ': true, '.': true, '!': true, '?': true, ':': true, ';': true, '\n': true, '<': true, '>': true, '(': true, ')': true, '{': true, '}': true, '[': true, ']': true, '+': true} +var SplitRunes = map[rune]bool{',': true, ' ': true, '.': true, '!': true, '?': true, ':': true, ';': true, '\n': true, '<': true, '>': true, '(': true, ')': true, '{': true, '}': true, '[': true, ']': true, '+': true, '/': true, '\\': true} -- cgit v1.2.3-1-g7c22