summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2017-03-06 17:06:27 -0500
committerChristopher Speller <crspeller@gmail.com>2017-03-06 17:06:27 -0500
commit3f070fe4b805e660cf796a5f851a0a1121a45fac (patch)
tree63e0927647114f6919a56934d161f9b2b78bc84c
parentfe3e3f7ef24e956a9f56acbac2b2a2d9c6dc4e81 (diff)
downloadchat-3f070fe4b805e660cf796a5f851a0a1121a45fac.tar.gz
chat-3f070fe4b805e660cf796a5f851a0a1121a45fac.tar.bz2
chat-3f070fe4b805e660cf796a5f851a0a1121a45fac.zip
PLT-5685 Fixing perf issue and problem with pushing for any activity (#5662)
* PLT-5685 Fixing perf issue and problem with pushing for any activity * PLT-5685 Fixing perf issue and problem with pushing for any activity
-rw-r--r--app/notification.go51
1 files changed, 21 insertions, 30 deletions
diff --git a/app/notification.go b/app/notification.go
index 3daaf64ce..469d114ee 100644
--- a/app/notification.go
+++ b/app/notification.go
@@ -117,38 +117,29 @@ func SendNotifications(post *model.Post, team *model.Team, channel *model.Channe
updateMentionChans = append(updateMentionChans, Srv.Store.Channel().IncrementMentionCount(post.ChannelId, id))
}
- senderName := make(map[string]string)
- channelName := make(map[string]string)
- for _, id := range mentionedUsersList {
- senderName[id] = ""
- if post.IsSystemMessage() {
- senderName[id] = utils.T("system.message.name")
+ senderName := ""
+ channelName := ""
+ if post.IsSystemMessage() {
+ senderName = utils.T("system.message.name")
+ } else {
+ if value, ok := post.Props["override_username"]; ok && post.Props["from_webhook"] == "true" {
+ senderName = value.(string)
} else {
- if value, ok := post.Props["override_username"]; ok && post.Props["from_webhook"] == "true" {
- senderName[id] = value.(string)
- } else {
- // Get the Display name preference from the receiver
- if result := <-Srv.Store.Preference().Get(id, model.PREFERENCE_CATEGORY_DISPLAY_SETTINGS, "name_format"); result.Err != nil {
- // Show default sender's name if user doesn't set display settings.
- senderName[id] = sender.Username
- } else {
- senderName[id] = sender.GetDisplayNameForPreference(result.Data.(model.Preference).Value)
- }
- }
+ senderName = sender.Username
}
+ }
- if channel.Type == model.CHANNEL_GROUP {
- userList := []*model.User{}
- for _, u := range profileMap {
- if u.Id != sender.Id && u.Id != id {
- userList = append(userList, u)
- }
+ if channel.Type == model.CHANNEL_GROUP {
+ userList := []*model.User{}
+ for _, u := range profileMap {
+ if u.Id != sender.Id {
+ userList = append(userList, u)
}
- userList = append(userList, sender)
- channelName[id] = model.GetGroupDisplayNameFromUsers(userList, false)
- } else {
- channelName[id] = channel.DisplayName
}
+ userList = append(userList, sender)
+ channelName = model.GetGroupDisplayNameFromUsers(userList, false)
+ } else {
+ channelName = channel.DisplayName
}
var senderUsername string
@@ -180,7 +171,7 @@ func SendNotifications(post *model.Post, team *model.Team, channel *model.Channe
}
if userAllowsEmails && status.Status != model.STATUS_ONLINE && profileMap[id].DeleteAt == 0 {
- sendNotificationEmail(post, profileMap[id], channel, team, senderName[id], sender)
+ sendNotificationEmail(post, profileMap[id], channel, team, senderName, sender)
}
}
}
@@ -273,7 +264,7 @@ func SendNotifications(post *model.Post, team *model.Team, channel *model.Channe
}
if ShouldSendPushNotification(profileMap[id], channelMemberNotifyPropsMap[id], true, status, post) {
- sendPushNotification(post, profileMap[id], channel, senderName[id], channelName[id], true)
+ sendPushNotification(post, profileMap[id], channel, senderName, channelName, true)
}
}
@@ -286,7 +277,7 @@ func SendNotifications(post *model.Post, team *model.Team, channel *model.Channe
}
if ShouldSendPushNotification(profileMap[id], channelMemberNotifyPropsMap[id], false, status, post) {
- sendPushNotification(post, profileMap[id], channel, senderName[id], channelName[id], false)
+ sendPushNotification(post, profileMap[id], channel, senderName, channelName, false)
}
}
}