Skip to content

Commit 7ffc242

Browse files
jamesorlakinzeripathlafriks
authored
Show the username as a fallback on feeds if full name is blank (#10438)
Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: Lauris BH <lauris@nix.lv>
1 parent ef798d4 commit 7ffc242

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

models/action.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,13 @@ func (a *Action) ShortActUserName() string {
120120
return base.EllipsisString(a.GetActUserName(), 20)
121121
}
122122

123-
// GetDisplayName gets the action's display name based on DEFAULT_SHOW_FULL_NAME
123+
// GetDisplayName gets the action's display name based on DEFAULT_SHOW_FULL_NAME, or falls back to the username if it is blank.
124124
func (a *Action) GetDisplayName() string {
125125
if setting.UI.DefaultShowFullName {
126-
return a.GetActFullName()
126+
trimmedFullName := strings.TrimSpace(a.GetActFullName())
127+
if len(trimmedFullName) > 0 {
128+
return trimmedFullName
129+
}
127130
}
128131
return a.ShortActUserName()
129132
}

models/user.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -739,9 +739,11 @@ func (u *User) DisplayName() string {
739739
// GetDisplayName returns full name if it's not empty and DEFAULT_SHOW_FULL_NAME is set,
740740
// returns username otherwise.
741741
func (u *User) GetDisplayName() string {
742-
trimmed := strings.TrimSpace(u.FullName)
743-
if len(trimmed) > 0 && setting.UI.DefaultShowFullName {
744-
return trimmed
742+
if setting.UI.DefaultShowFullName {
743+
trimmed := strings.TrimSpace(u.FullName)
744+
if len(trimmed) > 0 {
745+
return trimmed
746+
}
745747
}
746748
return u.Name
747749
}

0 commit comments

Comments
 (0)