diff --git a/models/action.go b/models/action.go index b8694aad73..267a19bc62 100644 --- a/models/action.go +++ b/models/action.go @@ -120,10 +120,13 @@ func (a *Action) ShortActUserName() string { return base.EllipsisString(a.GetActUserName(), 20) } -// GetDisplayName gets the action's display name based on DEFAULT_SHOW_FULL_NAME +// GetDisplayName gets the action's display name based on DEFAULT_SHOW_FULL_NAME, or falls back to the username if it is blank. func (a *Action) GetDisplayName() string { if setting.UI.DefaultShowFullName { - return a.GetActFullName() + trimmedFullName := strings.TrimSpace(a.GetActFullName()) + if len(trimmedFullName) > 0 { + return trimmedFullName + } } return a.ShortActUserName() } diff --git a/models/user.go b/models/user.go index 8be15ba6df..30ede2373e 100644 --- a/models/user.go +++ b/models/user.go @@ -739,9 +739,11 @@ func (u *User) DisplayName() string { // GetDisplayName returns full name if it's not empty and DEFAULT_SHOW_FULL_NAME is set, // returns username otherwise. func (u *User) GetDisplayName() string { - trimmed := strings.TrimSpace(u.FullName) - if len(trimmed) > 0 && setting.UI.DefaultShowFullName { - return trimmed + if setting.UI.DefaultShowFullName { + trimmed := strings.TrimSpace(u.FullName) + if len(trimmed) > 0 { + return trimmed + } } return u.Name }