Push and Email Notifications should follow "Teammate Name Display" setting (#4660)

* Push Notifications and Email Notifications should follow "Teammate Name Display" setting

* get the display name notification from the receiver
Этот коммит содержится в:
Carlos Tadeu Panato Junior
2016-12-08 00:14:04 +01:00
коммит произвёл Harrison Healey
родитель 7399d349de
Коммит 53cd544710

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

@@ -657,18 +657,26 @@ func sendNotifications(c *Context, post *model.Post, team *model.Team, channel *
updateMentionChans = append(updateMentionChans, Srv.Store.Channel().IncrementMentionCount(post.ChannelId, id))
}
senderName := ""
var sender *model.User
if post.IsSystemMessage() {
senderName = c.T("system.message.name")
} else if profile, ok := profileMap[post.UserId]; ok {
if value, ok := post.Props["override_username"]; ok && post.Props["from_webhook"] == "true" {
senderName = value.(string)
} else {
senderName = profile.Username
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 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] = profile.Username
} else {
senderName[id] = profile.GetDisplayNameForPreference(result.Data.(model.Preference).Value)
}
}
sender = profile
}
sender = profile
}
if utils.Cfg.EmailSettings.SendEmailNotifications {
@@ -688,7 +696,7 @@ func sendNotifications(c *Context, post *model.Post, team *model.Team, channel *
}
if userAllowsEmails && status.Status != model.STATUS_ONLINE {
go sendNotificationEmail(c, post, profileMap[id], channel, team, senderName, sender)
go sendNotificationEmail(c, post, profileMap[id], channel, team, senderName[id], sender)
}
}
}
@@ -784,7 +792,7 @@ func sendNotifications(c *Context, post *model.Post, team *model.Team, channel *
}
if DoesStatusAllowPushNotification(profileMap[id], status, post.ChannelId) {
go sendPushNotification(post, profileMap[id], channel, senderName, true)
go sendPushNotification(post, profileMap[id], channel, senderName[id], true)
}
}
@@ -797,7 +805,7 @@ func sendNotifications(c *Context, post *model.Post, team *model.Team, channel *
}
if DoesStatusAllowPushNotification(profileMap[id], status, post.ChannelId) {
go sendPushNotification(post, profileMap[id], channel, senderName, false)
go sendPushNotification(post, profileMap[id], channel, senderName[id], false)
}
}
}
@@ -908,14 +916,6 @@ func sendNotificationEmail(c *Context, post *model.Post, user *model.User, chann
subjectText = userLocale("api.post.send_notifications_and_forget.message_subject")
senderDisplayName := senderName
if sender != nil {
if result := <-Srv.Store.Preference().Get(user.Id, model.PREFERENCE_CATEGORY_DISPLAY_SETTINGS, "name_format"); result.Err != nil {
// Show default sender's name if user doesn't set display settings.
senderDisplayName = senderName
} else {
senderDisplayName = sender.GetDisplayNameForPreference(result.Data.(model.Preference).Value)
}
}
mailTemplate = "api.templates.post_subject_in_direct_message"
mailParameters = map[string]interface{}{"SubjectText": subjectText, "TeamDisplayName": team.DisplayName,