MM-18126 Respect show full name config setting in push and email notifications (#11996)
* Respect show full name config setting in push and email notifications * Style fix
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
f76fdc99d8
Коммит
c91bcd130d
@@ -786,3 +786,16 @@ func (e *ExplicitMentions) processText(text string, keywords map[string][]string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) GetNotificationNameFormat(user *model.User) string {
|
||||
if !*a.Config().PrivacySettings.ShowFullName {
|
||||
return model.SHOW_USERNAME
|
||||
}
|
||||
|
||||
data, err := a.Srv.Store.Preference().Get(user.Id, model.PREFERENCE_CATEGORY_DISPLAY_SETTINGS, model.PREFERENCE_NAME_NAME_FORMAT)
|
||||
if err != nil {
|
||||
return *a.Config().TeamSettings.TeammateNameDisplay
|
||||
}
|
||||
|
||||
return data.Value
|
||||
}
|
||||
|
||||
@@ -74,12 +74,7 @@ func (a *App) sendNotificationEmail(notification *postNotification, user *model.
|
||||
useMilitaryTime = data.Value == "true"
|
||||
}
|
||||
|
||||
var nameFormat string
|
||||
if data, err := a.Srv.Store.Preference().Get(user.Id, model.PREFERENCE_CATEGORY_DISPLAY_SETTINGS, model.PREFERENCE_NAME_NAME_FORMAT); err != nil {
|
||||
nameFormat = *a.Config().TeamSettings.TeammateNameDisplay
|
||||
} else {
|
||||
nameFormat = data.Value
|
||||
}
|
||||
nameFormat := a.GetNotificationNameFormat(user)
|
||||
|
||||
channelName := notification.GetChannelName(nameFormat, "")
|
||||
senderName := notification.GetSenderName(nameFormat, *a.Config().ServiceSettings.EnablePostUsernameOverride)
|
||||
|
||||
@@ -109,12 +109,7 @@ func (a *App) sendPushNotification(notification *postNotification, user *model.U
|
||||
channel := notification.channel
|
||||
post := notification.post
|
||||
|
||||
var nameFormat string
|
||||
if data, err := a.Srv.Store.Preference().Get(user.Id, model.PREFERENCE_CATEGORY_DISPLAY_SETTINGS, model.PREFERENCE_NAME_NAME_FORMAT); err != nil {
|
||||
nameFormat = *a.Config().TeamSettings.TeammateNameDisplay
|
||||
} else {
|
||||
nameFormat = data.Value
|
||||
}
|
||||
nameFormat := a.GetNotificationNameFormat(user)
|
||||
|
||||
channelName := notification.GetChannelName(nameFormat, user.Id)
|
||||
senderName := notification.GetSenderName(nameFormat, *cfg.ServiceSettings.EnablePostUsernameOverride)
|
||||
|
||||
@@ -1766,3 +1766,26 @@ func TestProcessText(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetNotificationNameFormat(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
t.Run("show full name on", func(t *testing.T) {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.PrivacySettings.ShowFullName = true
|
||||
*cfg.TeamSettings.TeammateNameDisplay = model.SHOW_FULLNAME
|
||||
})
|
||||
|
||||
assert.Equal(t, model.SHOW_FULLNAME, th.App.GetNotificationNameFormat(th.BasicUser))
|
||||
})
|
||||
|
||||
t.Run("show full name off", func(t *testing.T) {
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.PrivacySettings.ShowFullName = false
|
||||
*cfg.TeamSettings.TeammateNameDisplay = model.SHOW_FULLNAME
|
||||
})
|
||||
|
||||
assert.Equal(t, model.SHOW_USERNAME, th.App.GetNotificationNameFormat(th.BasicUser))
|
||||
})
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user