Merge pull request #1677 from hmhealey/plt1244
PLT-1244 Changed serverside mention parsing to support usernames containing periods
Этот коммит содержится в:
53
api/post.go
53
api/post.go
@@ -491,35 +491,52 @@ func sendNotificationsAndForget(c *Context, post *model.Post, team *model.Team,
|
|||||||
splitF := func(c rune) bool {
|
splitF := func(c rune) bool {
|
||||||
return model.SplitRunes[c]
|
return model.SplitRunes[c]
|
||||||
}
|
}
|
||||||
splitMessage := strings.FieldsFunc(post.Message, splitF)
|
splitMessage := strings.Fields(post.Message)
|
||||||
for _, word := range splitMessage {
|
for _, word := range splitMessage {
|
||||||
|
var userIds []string
|
||||||
|
|
||||||
// Non-case-sensitive check for regular keys
|
// Non-case-sensitive check for regular keys
|
||||||
userIds1, keyMatch := keywordMap[strings.ToLower(word)]
|
if ids, match := keywordMap[strings.ToLower(word)]; match {
|
||||||
|
userIds = append(userIds, ids...)
|
||||||
|
}
|
||||||
|
|
||||||
// Case-sensitive check for first name
|
// Case-sensitive check for first name
|
||||||
userIds2, firstNameMatch := keywordMap[word]
|
if ids, match := keywordMap[word]; match {
|
||||||
|
userIds = append(userIds, ids...)
|
||||||
|
}
|
||||||
|
|
||||||
userIds := append(userIds1, userIds2...)
|
if len(userIds) == 0 {
|
||||||
|
// No matches were found with the string split just on whitespace so try further splitting
|
||||||
|
// the message on punctuation
|
||||||
|
splitWords := strings.FieldsFunc(word, splitF)
|
||||||
|
|
||||||
// If one of the non-case-senstive keys or the first name matches the word
|
for _, splitWord := range splitWords {
|
||||||
// then we add en entry to the sendEmail map
|
// Non-case-sensitive check for regular keys
|
||||||
if keyMatch || firstNameMatch {
|
if ids, match := keywordMap[strings.ToLower(splitWord)]; match {
|
||||||
for _, userId := range userIds {
|
userIds = append(userIds, ids...)
|
||||||
if post.UserId == userId {
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
sendEmail := true
|
|
||||||
if _, ok := profileMap[userId].NotifyProps["email"]; ok && profileMap[userId].NotifyProps["email"] == "false" {
|
// Case-sensitive check for first name
|
||||||
sendEmail = false
|
if ids, match := keywordMap[splitWord]; match {
|
||||||
}
|
userIds = append(userIds, ids...)
|
||||||
if sendEmail && (profileMap[userId].IsAway() || profileMap[userId].IsOffline()) {
|
|
||||||
toEmailMap[userId] = true
|
|
||||||
} else {
|
|
||||||
toEmailMap[userId] = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, userId := range userIds {
|
||||||
|
if post.UserId == userId {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
sendEmail := true
|
||||||
|
if _, ok := profileMap[userId].NotifyProps["email"]; ok && profileMap[userId].NotifyProps["email"] == "false" {
|
||||||
|
sendEmail = false
|
||||||
|
}
|
||||||
|
if sendEmail && (profileMap[userId].IsAway() || profileMap[userId].IsOffline()) {
|
||||||
|
toEmailMap[userId] = true
|
||||||
|
} else {
|
||||||
|
toEmailMap[userId] = false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for id := range toEmailMap {
|
for id := range toEmailMap {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user