diff --git a/internal/forgejo/client_test.go b/internal/forgejo/client_test.go index 984f2d5..8f3e441 100644 --- a/internal/forgejo/client_test.go +++ b/internal/forgejo/client_test.go @@ -233,6 +233,26 @@ func TestStripCommentFooter_MultipleFooters(t *testing.T) { } } +func TestStripCommentFooter_SubmittedByNameAndEmail(t *testing.T) { + body, attribution := StripCommentFooter("Description\n\n---\n*Submitted by: John Doe *") + if body != "Description" { + t.Errorf("expected body %q, got %q", "Description", body) + } + if attribution != "John Doe " { + t.Errorf("expected attribution %q, got %q", "John Doe ", attribution) + } +} + +func TestStripCommentFooter_CustomerCommentByNameAndEmail(t *testing.T) { + body, attribution := StripCommentFooter("Reply\n\n---\n*Customer comment by: Alice Smith *") + if body != "Reply" { + t.Errorf("expected body %q, got %q", "Reply", body) + } + if attribution != "Alice Smith " { + t.Errorf("expected attribution %q, got %q", "Alice Smith ", attribution) + } +} + func TestStripCommentFooter_MarkdownHorizontalRule(t *testing.T) { input := "Text\n\n---\n\nMore text" body, email := StripCommentFooter(input) diff --git a/internal/handlers/public/tickets.go b/internal/handlers/public/tickets.go index d43287e..de704bb 100644 --- a/internal/handlers/public/tickets.go +++ b/internal/handlers/public/tickets.go @@ -201,7 +201,7 @@ func (h *TicketHandler) Create(c *gin.Context) { issue, err := h.deps.ForgejoClient.CreateIssue(repo.ForgejoOwner, repo.ForgejoRepo, forgejo.CreateIssueRequest{ Title: title, - Body: description + "\n\n---\n*Submitted by: " + user.Email + "*", + Body: description + "\n\n---\n*Submitted by: " + user.Name + " <" + user.Email + ">*", Labels: labelIDs, }) if err != nil { @@ -449,7 +449,7 @@ func (h *TicketHandler) AddComment(c *gin.Context) { } comment, err := h.deps.ForgejoClient.CreateComment(repo.ForgejoOwner, repo.ForgejoRepo, ticket.ForgejoIssueNumber, forgejo.CreateCommentRequest{ - Body: commentBody + "\n\n---\n*Customer comment by: " + user.Email + "*", + Body: commentBody + "\n\n---\n*Customer comment by: " + user.Name + " <" + user.Email + ">*", }) if err != nil { log.Error().Err(err).Msg("forgejo create comment error") diff --git a/web/templates/pages/admin/tickets/detail.html b/web/templates/pages/admin/tickets/detail.html index adf3ac5..d1ff8cf 100644 --- a/web/templates/pages/admin/tickets/detail.html +++ b/web/templates/pages/admin/tickets/detail.html @@ -15,7 +15,7 @@

{{if .Repo}}{{.Repo.Name}} · {{end}} - {{if .User}}by {{.User.Email}} · {{end}} + {{if .User}}by {{.User.Name}} <{{.User.Email}}> · {{end}} Created {{formatDate .Ticket.CreatedAt}} {{if .Ticket.ForgejoIssueNumber}} · Forgejo #{{.Ticket.ForgejoIssueNumber}}{{end}}

diff --git a/web/templates/pages/admin/tickets/list.html b/web/templates/pages/admin/tickets/list.html index e01f157..6512e3a 100644 --- a/web/templates/pages/admin/tickets/list.html +++ b/web/templates/pages/admin/tickets/list.html @@ -34,7 +34,7 @@ {{.Title}} - {{.UserEmail}} + {{.UserName}} {{.RepoName}} {{if .Priority}}{{priorityBadge .Priority}}{{end}} {{statusBadge (print .Status)}} diff --git a/web/templates/partials/nav.html b/web/templates/partials/nav.html index 89fcc11..b8fd2bb 100644 --- a/web/templates/partials/nav.html +++ b/web/templates/partials/nav.html @@ -7,7 +7,7 @@ {{if .User}} My Tickets New Ticket - {{.User.Email}} + {{.User.Name}}