diff options
author | James Lakin <jamesorlakin@users.noreply.github.com> | 2020-02-27 01:59:07 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-26 20:59:07 -0500 |
commit | 7bf5834f2c5dba71464e5af670c8d7f49fa1c743 (patch) | |
tree | e382d1f917c1ec4b6be86e434eb1bd7908aeb142 | |
parent | 1fbdd9335fdeda50c63ceee593547e3dccae7532 (diff) | |
download | gitea-7bf5834f2c5dba71464e5af670c8d7f49fa1c743.tar.gz gitea-7bf5834f2c5dba71464e5af670c8d7f49fa1c743.zip |
Show the username as a fallback on feeds if full name is blank (#10461)
Co-authored-by: Lauris BH <lauris@nix.lv>
-rw-r--r-- | models/action.go | 7 | ||||
-rw-r--r-- | models/user.go | 8 |
2 files changed, 10 insertions, 5 deletions
diff --git a/models/action.go b/models/action.go index 3bc88f0063..cd722cbe7c 100644 --- a/models/action.go +++ b/models/action.go @@ -122,10 +122,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 d8c0fcf47d..4cc14664db 100644 --- a/models/user.go +++ b/models/user.go @@ -712,9 +712,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 } |