Skip to content

Commit 7bf5834

Browse files
Show the username as a fallback on feeds if full name is blank (#10461)
Co-authored-by: Lauris BH <[email protected]>
1 parent 1fbdd93 commit 7bf5834

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

models/action.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,13 @@ func (a *Action) ShortActUserName() string {
122122
return base.EllipsisString(a.GetActUserName(), 20)
123123
}
124124

125-
// GetDisplayName gets the action's display name based on DEFAULT_SHOW_FULL_NAME
125+
// GetDisplayName gets the action's display name based on DEFAULT_SHOW_FULL_NAME, or falls back to the username if it is blank.
126126
func (a *Action) GetDisplayName() string {
127127
if setting.UI.DefaultShowFullName {
128-
return a.GetActFullName()
128+
trimmedFullName := strings.TrimSpace(a.GetActFullName())
129+
if len(trimmedFullName) > 0 {
130+
return trimmedFullName
131+
}
129132
}
130133
return a.ShortActUserName()
131134
}

models/user.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -712,9 +712,11 @@ func (u *User) DisplayName() string {
712712
// GetDisplayName returns full name if it's not empty and DEFAULT_SHOW_FULL_NAME is set,
713713
// returns username otherwise.
714714
func (u *User) GetDisplayName() string {
715-
trimmed := strings.TrimSpace(u.FullName)
716-
if len(trimmed) > 0 && setting.UI.DefaultShowFullName {
717-
return trimmed
715+
if setting.UI.DefaultShowFullName {
716+
trimmed := strings.TrimSpace(u.FullName)
717+
if len(trimmed) > 0 {
718+
return trimmed
719+
}
718720
}
719721
return u.Name
720722
}

0 commit comments

Comments
 (0)