Skip to content

Commit abccb86

Browse files
authored
Show bot label next to username when rendering autor link if the user is a bot (#24943)
If the user is a bot, we'll add a label next to the author link that says `bot`. I didn't localize `bot` because passing `locale` into the `autorlink` template would require changing all calls. # Example `yardenshoham` is a bot. ## Before ![image](https://github.com/go-gitea/gitea/assets/20454870/77390780-b763-4f0f-b358-bbccdbf17a5d) ## After ![image](https://github.com/go-gitea/gitea/assets/20454870/72af342f-ee76-4337-95ad-4ecaba853fed) --------- Signed-off-by: Yarden Shoham <[email protected]>
1 parent 85fa954 commit abccb86

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

models/user/user.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,11 @@ func (u *User) IsIndividual() bool {
406406
return u.Type == UserTypeIndividual
407407
}
408408

409+
// IsBot returns whether or not the user is of type bot
410+
func (u *User) IsBot() bool {
411+
return u.Type == UserTypeBot
412+
}
413+
409414
// DisplayName returns full name if it's not empty,
410415
// returns username otherwise.
411416
func (u *User) DisplayName() string {

templates/shared/user/authorlink.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<a class="author text black gt-font-semibold muted"{{if gt .ID 0}} href="{{.HomeLink}}"{{end}}>{{.GetDisplayName}}</a>
1+
<a class="author text black gt-font-semibold muted"{{if gt .ID 0}} href="{{.HomeLink}}"{{end}}>{{.GetDisplayName}}</a>{{if .IsBot}}<span class="ui basic label gt-p-2">bot</span>{{end}}

0 commit comments

Comments
 (0)