summaryrefslogtreecommitdiffstats
path: root/api/post.go
diff options
context:
space:
mode:
authorCarlos Tadeu Panato Junior <ctadeu@gmail.com>2016-12-08 00:14:04 +0100
committerHarrison Healey <harrisonmhealey@gmail.com>2016-12-07 18:14:04 -0500
commit53cd54471044cff18d1a5b9e88b1e1d917684541 (patch)
treee6958e47f4fe0de70c1963fe7811451514fea54e /api/post.go
parent7399d349dedc35c8c05b223a3c143a420bf2411f (diff)
downloadchat-53cd54471044cff18d1a5b9e88b1e1d917684541.tar.gz
chat-53cd54471044cff18d1a5b9e88b1e1d917684541.tar.bz2
chat-53cd54471044cff18d1a5b9e88b1e1d917684541.zip
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
Diffstat (limited to 'api/post.go')
-rw-r--r--api/post.go42
1 files changed, 21 insertions, 21 deletions
diff --git a/api/post.go b/api/post.go
index 2dc574e9b..fcbafbbe5 100644
--- a/api/post.go
+++ b/api/post.go
@@ -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,