From fee62fed53514a9aabf95a2d9acc0dd507104b6f Mon Sep 17 00:00:00 2001 From: Matthew Knight Date: Sat, 14 Feb 2026 02:17:09 -0800 Subject: [PATCH] better display --- internal/forgejo/client.go | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/internal/forgejo/client.go b/internal/forgejo/client.go index 40ecd4c..8671d2e 100644 --- a/internal/forgejo/client.go +++ b/internal/forgejo/client.go @@ -68,6 +68,18 @@ type Comment struct { type APIUser struct { Login string `json:"login"` FullName string `json:"full_name"` + Email string `json:"email"` +} + +// DisplayName returns the best human-readable name for the user. +func (u APIUser) DisplayName() string { + if u.FullName != "" { + return u.FullName + } + if u.Email != "" { + return u.Email + } + return u.Login } type CommentView struct { @@ -111,12 +123,16 @@ func StripCommentFooter(body string) (string, string) { } // BuildCommentViews transforms Forgejo comments into view models, -// identifying customer vs team comments based on the bot login. +// identifying customer vs team comments. A comment is considered a +// customer comment if it has a recognizable footer (primary check) OR +// if its author matches the bot login (fallback). func BuildCommentViews(comments []Comment, botLogin string) []CommentView { var views []CommentView for _, c := range comments { - if c.User.Login == botLogin { - body, email := StripCommentFooter(c.Body) + body, email := StripCommentFooter(c.Body) + isCustomer := email != "" || (botLogin != "" && c.User.Login == botLogin) + + if isCustomer { authorName := email if authorName == "" { authorName = "Customer" @@ -128,13 +144,9 @@ func BuildCommentViews(comments []Comment, botLogin string) []CommentView { CreatedAt: c.CreatedAt, }) } else { - name := c.User.FullName - if name == "" { - name = c.User.Login - } views = append(views, CommentView{ Body: c.Body, - AuthorName: name, + AuthorName: c.User.DisplayName(), IsTeam: true, CreatedAt: c.CreatedAt, })