summaryrefslogtreecommitdiffstats
path: root/app/notification_email.go
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2018-09-17 14:50:12 -0400
committerSudheer <sudheer.105@gmail.com>2018-09-18 00:20:12 +0530
commit6c2a5555b85bd15106df5f4f631bb6e945a187b8 (patch)
treed1267e537a741171a50ddec4ff08e11e9e5dbd26 /app/notification_email.go
parentab99f0656fabed8a62a8c6340be7d538cc7bf8d9 (diff)
downloadchat-6c2a5555b85bd15106df5f4f631bb6e945a187b8.tar.gz
chat-6c2a5555b85bd15106df5f4f631bb6e945a187b8.tar.bz2
chat-6c2a5555b85bd15106df5f4f631bb6e945a187b8.zip
MM-11700 Clean up handling of user display names for notifications (#9343)
* MM-11700 Clean up handling of user display names for notifications
Diffstat (limited to 'app/notification_email.go')
-rw-r--r--app/notification_email.go23
1 files changed, 19 insertions, 4 deletions
diff --git a/app/notification_email.go b/app/notification_email.go
index b3835a4ee..cfc1bb4fd 100644
--- a/app/notification_email.go
+++ b/app/notification_email.go
@@ -17,7 +17,10 @@ import (
"github.com/nicksnyder/go-i18n/i18n"
)
-func (a *App) sendNotificationEmail(post *model.Post, user *model.User, channel *model.Channel, team *model.Team, channelName string, senderName string, sender *model.User) *model.AppError {
+func (a *App) sendNotificationEmail(notification *postNotification, user *model.User, team *model.Team) *model.AppError {
+ channel := notification.channel
+ post := notification.post
+
if channel.IsGroupOrDirect() {
if result := <-a.Srv.Store.Team().GetTeamsByUserId(user.Id); result.Err != nil {
return result.Err
@@ -41,6 +44,7 @@ func (a *App) sendNotificationEmail(post *model.Post, user *model.User, channel
}
}
}
+
if *a.Config().EmailSettings.EnableEmailBatching {
var sendBatched bool
if result := <-a.Srv.Store.Preference().Get(user.Id, model.PREFERENCE_CATEGORY_NOTIFICATIONS, model.PREFERENCE_NAME_EMAIL_INTERVAL); result.Err != nil {
@@ -60,14 +64,25 @@ func (a *App) sendNotificationEmail(post *model.Post, user *model.User, channel
// fall back to sending a single email if we can't batch it for some reason
}
- var useMilitaryTime bool
translateFunc := utils.GetUserTranslations(user.Locale)
- if result := <-a.Srv.Store.Preference().Get(user.Id, model.PREFERENCE_CATEGORY_DISPLAY_SETTINGS, "use_military_time"); result.Err != nil {
+
+ var useMilitaryTime bool
+ if result := <-a.Srv.Store.Preference().Get(user.Id, model.PREFERENCE_CATEGORY_DISPLAY_SETTINGS, model.PREFERENCE_NAME_USE_MILITARY_TIME); result.Err != nil {
useMilitaryTime = true
} else {
useMilitaryTime = result.Data.(model.Preference).Value == "true"
}
+ var nameFormat string
+ if result := <-a.Srv.Store.Preference().Get(user.Id, model.PREFERENCE_CATEGORY_DISPLAY_SETTINGS, model.PREFERENCE_NAME_NAME_FORMAT); result.Err != nil {
+ nameFormat = *a.Config().TeamSettings.TeammateNameDisplay
+ } else {
+ nameFormat = result.Data.(model.Preference).Value
+ }
+
+ channelName := notification.GetChannelName(nameFormat, "")
+ senderName := notification.GetSenderName(nameFormat, a.Config().ServiceSettings.EnablePostUsernameOverride)
+
emailNotificationContentsType := model.EMAIL_NOTIFICATION_CONTENTS_FULL
if license := a.License(); license != nil && *license.Features.EmailNotificationContents {
emailNotificationContentsType = *a.Config().EmailSettings.EmailNotificationContentsType
@@ -79,7 +94,7 @@ func (a *App) sendNotificationEmail(post *model.Post, user *model.User, channel
} else if channel.Type == model.CHANNEL_GROUP {
subjectText = getGroupMessageNotificationEmailSubject(user, post, translateFunc, a.Config().TeamSettings.SiteName, channelName, emailNotificationContentsType, useMilitaryTime)
} else if *a.Config().EmailSettings.UseChannelInEmailNotifications {
- subjectText = getNotificationEmailSubject(user, post, translateFunc, a.Config().TeamSettings.SiteName, team.DisplayName+" ("+channel.DisplayName+")", useMilitaryTime)
+ subjectText = getNotificationEmailSubject(user, post, translateFunc, a.Config().TeamSettings.SiteName, team.DisplayName+" ("+channelName+")", useMilitaryTime)
} else {
subjectText = getNotificationEmailSubject(user, post, translateFunc, a.Config().TeamSettings.SiteName, team.DisplayName, useMilitaryTime)
}