Fixing bulk loading perf issue (#4974)

Этот коммит содержится в:
Corey Hulen
2017-01-06 10:03:31 -05:00
коммит произвёл Harrison Healey
родитель d4e88fde21
Коммит 4fb9787fee

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

@@ -573,8 +573,15 @@ func getExplicitMentions(message string, keywords map[string][]string) (map[stri
}
func sendNotifications(c *Context, post *model.Post, team *model.Team, channel *model.Channel) []string {
mentionedUsersList := make([]string, 0)
var fchan store.StoreChannel
var senderUsername string
if post.IsSystemMessage() {
senderUsername = c.T("system.message.name")
} else {
pchan := Srv.Store.User().GetProfilesInChannel(channel.Id, -1, -1, true)
fchan := Srv.Store.FileInfo().GetForPost(post.Id)
fchan = Srv.Store.FileInfo().GetForPost(post.Id)
var profileMap map[string]*model.User
if result := <-pchan; result.Err != nil {
@@ -648,14 +655,13 @@ func sendNotifications(c *Context, post *model.Post, team *model.Team, channel *
// find which users in the channel are set up to always receive mobile notifications
for _, profile := range profileMap {
if profile.NotifyProps["push"] == model.USER_NOTIFY_ALL &&
(post.UserId != profile.Id || post.Props["from_webhook"] == "true") &&
!post.IsSystemMessage() {
(post.UserId != profile.Id || post.Props["from_webhook"] == "true") {
allActivityPushUserIds = append(allActivityPushUserIds, profile.Id)
}
}
}
mentionedUsersList := make([]string, 0, len(mentionedUserIds))
mentionedUsersList = make([]string, 0, len(mentionedUserIds))
for id := range mentionedUserIds {
mentionedUsersList = append(mentionedUsersList, id)
updateMentionChans = append(updateMentionChans, Srv.Store.Channel().IncrementMentionCount(post.ChannelId, id))
@@ -665,9 +671,7 @@ func sendNotifications(c *Context, post *model.Post, team *model.Team, channel *
senderName := make(map[string]string)
for _, id := range mentionedUsersList {
senderName[id] = ""
if post.IsSystemMessage() {
senderName[id] = c.T("system.message.name")
} else if profile, ok := profileMap[post.UserId]; ok {
if profile, ok := profileMap[post.UserId]; ok {
if value, ok := post.Props["override_username"]; ok && post.Props["from_webhook"] == "true" {
senderName[id] = value.(string)
} else {
@@ -683,7 +687,6 @@ func sendNotifications(c *Context, post *model.Post, team *model.Team, channel *
}
}
var senderUsername string
if value, ok := post.Props["override_username"]; ok && post.Props["from_webhook"] == "true" {
senderUsername = value.(string)
} else {
@@ -821,6 +824,7 @@ func sendNotifications(c *Context, post *model.Post, team *model.Team, channel *
}
}
}
}
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_POSTED, "", post.ChannelId, "", nil)
message.Add("post", post.ToJson())
@@ -830,7 +834,7 @@ func sendNotifications(c *Context, post *model.Post, team *model.Team, channel *
message.Add("sender_name", senderUsername)
message.Add("team_id", team.Id)
if len(post.FileIds) != 0 {
if len(post.FileIds) != 0 && fchan != nil {
message.Add("otherFile", "true")
var infos []*model.FileInfo