summaryrefslogtreecommitdiffstats
path: root/app/notification.go
diff options
context:
space:
mode:
authorcpanato <ctadeu@gmail.com>2018-07-12 19:50:16 +0200
committercpanato <ctadeu@gmail.com>2018-07-12 19:50:16 +0200
commitadc56ae78df2a84c14c5e2921ec9cb14817a2474 (patch)
treea66d4646ecc3baef4d365f7148fe3921ab267e15 /app/notification.go
parent8cad7070acc537d070edd1029fe0c6ce422ab0ed (diff)
parent2e861c4df4063f325df40861ee045c0136d34f1e (diff)
downloadchat-adc56ae78df2a84c14c5e2921ec9cb14817a2474.tar.gz
chat-adc56ae78df2a84c14c5e2921ec9cb14817a2474.tar.bz2
chat-adc56ae78df2a84c14c5e2921ec9cb14817a2474.zip
Merge remote-tracking branch 'upstream/release-5.1' into release-5.1-daily-merge-20180712
Diffstat (limited to 'app/notification.go')
-rw-r--r--app/notification.go36
1 files changed, 19 insertions, 17 deletions
diff --git a/app/notification.go b/app/notification.go
index 8da581c00..b4d36291d 100644
--- a/app/notification.go
+++ b/app/notification.go
@@ -694,26 +694,15 @@ func (a *App) GetMessageForNotification(post *model.Post, translateFunc i18n.Tra
func (a *App) sendPushNotification(post *model.Post, user *model.User, channel *model.Channel, channelName string, sender *model.User, senderName string,
explicitMention, channelWideMention bool, replyToThreadType string) *model.AppError {
- contentsConfig := *a.Config().EmailSettings.PushNotificationContents
+ cfg := a.Config()
+ contentsConfig := *cfg.EmailSettings.PushNotificationContents
+ teammateNameConfig := *cfg.TeamSettings.TeammateNameDisplay
sessions, err := a.getMobileAppSessions(user.Id)
+ sentBySystem := senderName == utils.T("system.message.name")
if err != nil {
return err
}
- if channel.Type == model.CHANNEL_DIRECT {
- if senderName == utils.T("system.message.name") {
- channelName = senderName
- } else {
- preference, prefError := a.GetPreferenceByCategoryAndNameForUser(user.Id, model.PREFERENCE_CATEGORY_DISPLAY_SETTINGS, "name_format")
- if prefError != nil {
- channelName = fmt.Sprintf("@%v", senderName)
- } else {
- channelName = fmt.Sprintf("@%v", sender.GetDisplayName(preference.Value))
- senderName = channelName
- }
- }
- }
-
msg := model.PushNotification{}
if badge := <-a.Srv.Store.User().GetUnreadCount(user.Id); badge.Err != nil {
msg.Badge = 1
@@ -731,15 +720,28 @@ func (a *App) sendPushNotification(post *model.Post, user *model.User, channel *
msg.RootId = post.RootId
msg.SenderId = post.UserId
+ if !sentBySystem {
+ senderName = sender.GetDisplayName(teammateNameConfig)
+ preference, prefError := a.GetPreferenceByCategoryAndNameForUser(user.Id, model.PREFERENCE_CATEGORY_DISPLAY_SETTINGS, "name_format")
+ if prefError == nil && preference.Value != teammateNameConfig {
+ senderName = sender.GetDisplayName(preference.Value)
+ }
+ }
+
+ if channel.Type == model.CHANNEL_DIRECT {
+ channelName = fmt.Sprintf("@%v", senderName)
+ }
+
if contentsConfig != model.GENERIC_NO_CHANNEL_NOTIFICATION || channel.Type == model.CHANNEL_DIRECT {
msg.ChannelName = channelName
}
- if ou, ok := post.Props["override_username"].(string); ok {
+ if ou, ok := post.Props["override_username"].(string); ok && cfg.ServiceSettings.EnablePostUsernameOverride {
msg.OverrideUsername = ou
+ senderName = ou
}
- if oi, ok := post.Props["override_icon_url"].(string); ok {
+ if oi, ok := post.Props["override_icon_url"].(string); ok && cfg.ServiceSettings.EnablePostIconOverride {
msg.OverrideIconUrl = oi
}