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
Этот коммит содержится в:
Corey Hulen
2017-03-06 17:06:27 -05:00
коммит произвёл Christopher Speller
родитель fe3e3f7ef2
Коммит 3f070fe4b8

Просмотреть файл

@@ -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)) updateMentionChans = append(updateMentionChans, Srv.Store.Channel().IncrementMentionCount(post.ChannelId, id))
} }
senderName := make(map[string]string) senderName := ""
channelName := make(map[string]string) channelName := ""
for _, id := range mentionedUsersList { if post.IsSystemMessage() {
senderName[id] = "" senderName = utils.T("system.message.name")
if post.IsSystemMessage() { } else {
senderName[id] = utils.T("system.message.name") if value, ok := post.Props["override_username"]; ok && post.Props["from_webhook"] == "true" {
senderName = value.(string)
} else { } else {
if value, ok := post.Props["override_username"]; ok && post.Props["from_webhook"] == "true" { senderName = sender.Username
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)
}
}
} }
}
if channel.Type == model.CHANNEL_GROUP { if channel.Type == model.CHANNEL_GROUP {
userList := []*model.User{} userList := []*model.User{}
for _, u := range profileMap { for _, u := range profileMap {
if u.Id != sender.Id && u.Id != id { if u.Id != sender.Id {
userList = append(userList, u) 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 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 { 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) { 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) { 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)
} }
} }
} }