Merge pull request 'Use customer names in UI and tickets' (#6) from customer-full-name into main

Reviewed-on: https://git.ts.mattnite.net/mattnite/forgejo-tickets/pulls/6
This commit is contained in:
Matthew Knight 2026-02-16 23:14:54 +00:00
commit 1f3e1d3074
5 changed files with 25 additions and 5 deletions

View File

@ -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 <user@example.com>*")
if body != "Description" {
t.Errorf("expected body %q, got %q", "Description", body)
}
if attribution != "John Doe <user@example.com>" {
t.Errorf("expected attribution %q, got %q", "John Doe <user@example.com>", attribution)
}
}
func TestStripCommentFooter_CustomerCommentByNameAndEmail(t *testing.T) {
body, attribution := StripCommentFooter("Reply\n\n---\n*Customer comment by: Alice Smith <alice@corp.com>*")
if body != "Reply" {
t.Errorf("expected body %q, got %q", "Reply", body)
}
if attribution != "Alice Smith <alice@corp.com>" {
t.Errorf("expected attribution %q, got %q", "Alice Smith <alice@corp.com>", attribution)
}
}
func TestStripCommentFooter_MarkdownHorizontalRule(t *testing.T) { func TestStripCommentFooter_MarkdownHorizontalRule(t *testing.T) {
input := "Text\n\n---\n\nMore text" input := "Text\n\n---\n\nMore text"
body, email := StripCommentFooter(input) body, email := StripCommentFooter(input)

View File

@ -201,7 +201,7 @@ func (h *TicketHandler) Create(c *gin.Context) {
issue, err := h.deps.ForgejoClient.CreateIssue(repo.ForgejoOwner, repo.ForgejoRepo, forgejo.CreateIssueRequest{ issue, err := h.deps.ForgejoClient.CreateIssue(repo.ForgejoOwner, repo.ForgejoRepo, forgejo.CreateIssueRequest{
Title: title, Title: title,
Body: description + "\n\n---\n*Submitted by: " + user.Email + "*", Body: description + "\n\n---\n*Submitted by: " + user.Name + " <" + user.Email + ">*",
Labels: labelIDs, Labels: labelIDs,
}) })
if err != nil { 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{ 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 { if err != nil {
log.Error().Err(err).Msg("forgejo create comment error") log.Error().Err(err).Msg("forgejo create comment error")

View File

@ -15,7 +15,7 @@
</div> </div>
<p class="mt-1 text-sm text-gray-500"> <p class="mt-1 text-sm text-gray-500">
{{if .Repo}}{{.Repo.Name}} &middot; {{end}} {{if .Repo}}{{.Repo.Name}} &middot; {{end}}
{{if .User}}by {{.User.Email}} &middot; {{end}} {{if .User}}by {{.User.Name}} &lt;{{.User.Email}}&gt; &middot; {{end}}
Created {{formatDate .Ticket.CreatedAt}} Created {{formatDate .Ticket.CreatedAt}}
{{if .Ticket.ForgejoIssueNumber}} &middot; Forgejo #{{.Ticket.ForgejoIssueNumber}}{{end}} {{if .Ticket.ForgejoIssueNumber}} &middot; Forgejo #{{.Ticket.ForgejoIssueNumber}}{{end}}
</p> </p>

View File

@ -34,7 +34,7 @@
<a href="/tickets/{{.ID}}" class="text-sm font-medium text-blue-600 hover:text-blue-500">{{.Title}}</a> <a href="/tickets/{{.ID}}" class="text-sm font-medium text-blue-600 hover:text-blue-500">{{.Title}}</a>
</div> </div>
</td> </td>
<td class="px-4 py-3 text-sm text-gray-500">{{.UserEmail}}</td> <td class="px-4 py-3 text-sm text-gray-500">{{.UserName}}</td>
<td class="px-4 py-3 text-sm text-gray-500">{{.RepoName}}</td> <td class="px-4 py-3 text-sm text-gray-500">{{.RepoName}}</td>
<td class="px-4 py-3">{{if .Priority}}{{priorityBadge .Priority}}{{end}}</td> <td class="px-4 py-3">{{if .Priority}}{{priorityBadge .Priority}}{{end}}</td>
<td class="px-4 py-3">{{statusBadge (print .Status)}}</td> <td class="px-4 py-3">{{statusBadge (print .Status)}}</td>

View File

@ -7,7 +7,7 @@
{{if .User}} {{if .User}}
<a href="/tickets" class="text-sm font-medium text-gray-700 hover:text-gray-900">My Tickets</a> <a href="/tickets" class="text-sm font-medium text-gray-700 hover:text-gray-900">My Tickets</a>
<a href="/tickets/new" class="text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 px-3 py-1.5 rounded-md">New Ticket</a> <a href="/tickets/new" class="text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 px-3 py-1.5 rounded-md">New Ticket</a>
<span class="text-sm text-gray-500">{{.User.Email}}</span> <span class="text-sm text-gray-500">{{.User.Name}}</span>
<form method="POST" action="/logout" class="inline"> <form method="POST" action="/logout" class="inline">
<input type="hidden" name="gorilla.csrf.Token" value="{{.CSRFToken}}"> <input type="hidden" name="gorilla.csrf.Token" value="{{.CSRFToken}}">
<button type="submit" class="text-sm font-medium text-gray-500 hover:text-gray-700">Logout</button> <button type="submit" class="text-sm font-medium text-gray-500 hover:text-gray-700">Logout</button>