mirror of
https://github.com/go-gitea/gitea
synced 2024-12-01 12:22:47 +01:00
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>
This commit is contained in:
parent
ef798d4b84
commit
7ffc2427da
2 changed files with 10 additions and 5 deletions
|
@ -120,10 +120,13 @@ func (a *Action) ShortActUserName() string {
|
||||||
return base.EllipsisString(a.GetActUserName(), 20)
|
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 {
|
func (a *Action) GetDisplayName() string {
|
||||||
if setting.UI.DefaultShowFullName {
|
if setting.UI.DefaultShowFullName {
|
||||||
return a.GetActFullName()
|
trimmedFullName := strings.TrimSpace(a.GetActFullName())
|
||||||
|
if len(trimmedFullName) > 0 {
|
||||||
|
return trimmedFullName
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return a.ShortActUserName()
|
return a.ShortActUserName()
|
||||||
}
|
}
|
||||||
|
|
|
@ -739,10 +739,12 @@ func (u *User) DisplayName() string {
|
||||||
// GetDisplayName returns full name if it's not empty and DEFAULT_SHOW_FULL_NAME is set,
|
// GetDisplayName returns full name if it's not empty and DEFAULT_SHOW_FULL_NAME is set,
|
||||||
// returns username otherwise.
|
// returns username otherwise.
|
||||||
func (u *User) GetDisplayName() string {
|
func (u *User) GetDisplayName() string {
|
||||||
|
if setting.UI.DefaultShowFullName {
|
||||||
trimmed := strings.TrimSpace(u.FullName)
|
trimmed := strings.TrimSpace(u.FullName)
|
||||||
if len(trimmed) > 0 && setting.UI.DefaultShowFullName {
|
if len(trimmed) > 0 {
|
||||||
return trimmed
|
return trimmed
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return u.Name
|
return u.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue