Commit 89872606 authored by Jordi Mallach's avatar Jordi Mallach 🔥

Allow setting of SHOW_NICKNAME_USERNAME nameformat.

parent eeb95a8a
......@@ -51,6 +51,7 @@ const (
DIRECT_MESSAGE_TEAM = "team"
SHOW_USERNAME = "username"
SHOW_NICKNAME_USERNAME = "nickname_username"
SHOW_NICKNAME_FULLNAME = "nickname_full_name"
SHOW_FULLNAME = "full_name"
......@@ -2125,7 +2126,7 @@ func (ts *TeamSettings) isValid() *AppError {
return NewAppError("Config.IsValid", "model.config.is_valid.restrict_direct_message.app_error", nil, "", http.StatusBadRequest)
}
if !(*ts.TeammateNameDisplay == SHOW_FULLNAME || *ts.TeammateNameDisplay == SHOW_NICKNAME_FULLNAME || *ts.TeammateNameDisplay == SHOW_USERNAME) {
if !(*ts.TeammateNameDisplay == SHOW_FULLNAME || *ts.TeammateNameDisplay == SHOW_NICKNAME_FULLNAME || *ts.TeammateNameDisplay == SHOW_NICKNAME_USERNAME || *ts.TeammateNameDisplay == SHOW_USERNAME) {
return NewAppError("Config.IsValid", "model.config.is_valid.teammate_name_display.app_error", nil, "", http.StatusBadRequest)
}
......
......@@ -419,15 +419,16 @@ func (u *User) GetFullName() string {
func (u *User) GetDisplayName(nameFormat string) string {
displayName := u.Username
fullName := u.GetFullName()
if nameFormat == SHOW_NICKNAME_FULLNAME {
if nameFormat == SHOW_NICKNAME_FULLNAME || nameFormat == SHOW_NICKNAME_USERNAME {
if len(u.Nickname) > 0 {
displayName = u.Nickname
} else if fullName := u.GetFullName(); len(fullName) > 0 {
} else if nameFormat == SHOW_NICKNAME_FULLNAME && len(fullName) > 0 {
displayName = fullName
}
} else if nameFormat == SHOW_FULLNAME {
if fullName := u.GetFullName(); len(fullName) > 0 {
if len(fullName) > 0 {
displayName = fullName
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment