mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-01 06:48:56 +00:00
Show fullname on issue edits and gpg/ssh signing info (#18828)
Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
parent
db4c7dcf15
commit
36148ed083
4 changed files with 16 additions and 6 deletions
|
@ -137,6 +137,7 @@ func QueryIssueContentHistoryEditedCountMap(dbCtx context.Context, issueID int64
|
||||||
type IssueContentListItem struct {
|
type IssueContentListItem struct {
|
||||||
UserID int64
|
UserID int64
|
||||||
UserName string
|
UserName string
|
||||||
|
UserFullName string
|
||||||
UserAvatarLink string
|
UserAvatarLink string
|
||||||
|
|
||||||
HistoryID int64
|
HistoryID int64
|
||||||
|
@ -148,7 +149,7 @@ type IssueContentListItem struct {
|
||||||
// FetchIssueContentHistoryList fetch list
|
// FetchIssueContentHistoryList fetch list
|
||||||
func FetchIssueContentHistoryList(dbCtx context.Context, issueID, commentID int64) ([]*IssueContentListItem, error) {
|
func FetchIssueContentHistoryList(dbCtx context.Context, issueID, commentID int64) ([]*IssueContentListItem, error) {
|
||||||
res := make([]*IssueContentListItem, 0)
|
res := make([]*IssueContentListItem, 0)
|
||||||
err := db.GetEngine(dbCtx).Select("u.id as user_id, u.name as user_name,"+
|
err := db.GetEngine(dbCtx).Select("u.id as user_id, u.name as user_name, u.full_name as user_full_name,"+
|
||||||
"h.id as history_id, h.edited_unix, h.is_first_created, h.is_deleted").
|
"h.id as history_id, h.edited_unix, h.is_first_created, h.is_deleted").
|
||||||
Table([]string{"issue_content_history", "h"}).
|
Table([]string{"issue_content_history", "h"}).
|
||||||
Join("LEFT", []string{"user", "u"}, "h.poster_id = u.id").
|
Join("LEFT", []string{"user", "u"}, "h.poster_id = u.id").
|
||||||
|
|
|
@ -43,8 +43,9 @@ func TestContentHistory(t *testing.T) {
|
||||||
when the refactor of models are done, this test will be possible to be run then with a real `User` model.
|
when the refactor of models are done, this test will be possible to be run then with a real `User` model.
|
||||||
*/
|
*/
|
||||||
type User struct {
|
type User struct {
|
||||||
ID int64
|
ID int64
|
||||||
Name string
|
Name string
|
||||||
|
FullName string
|
||||||
}
|
}
|
||||||
_ = dbEngine.Sync2(&User{})
|
_ = dbEngine.Sync2(&User{})
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"html"
|
"html"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"code.gitea.io/gitea/models"
|
"code.gitea.io/gitea/models"
|
||||||
"code.gitea.io/gitea/models/db"
|
"code.gitea.io/gitea/models/db"
|
||||||
|
@ -16,6 +17,7 @@ import (
|
||||||
"code.gitea.io/gitea/models/unit"
|
"code.gitea.io/gitea/models/unit"
|
||||||
"code.gitea.io/gitea/modules/context"
|
"code.gitea.io/gitea/modules/context"
|
||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
|
"code.gitea.io/gitea/modules/setting"
|
||||||
"code.gitea.io/gitea/modules/timeutil"
|
"code.gitea.io/gitea/modules/timeutil"
|
||||||
|
|
||||||
"github.com/sergi/go-diff/diffmatchpatch"
|
"github.com/sergi/go-diff/diffmatchpatch"
|
||||||
|
@ -68,9 +70,15 @@ func GetContentHistoryList(ctx *context.Context) {
|
||||||
actionText = i18n.Tr(lang, "repo.issues.content_history.edited")
|
actionText = i18n.Tr(lang, "repo.issues.content_history.edited")
|
||||||
}
|
}
|
||||||
timeSinceText := timeutil.TimeSinceUnix(item.EditedUnix, lang)
|
timeSinceText := timeutil.TimeSinceUnix(item.EditedUnix, lang)
|
||||||
|
|
||||||
|
username := item.UserName
|
||||||
|
if setting.UI.DefaultShowFullName && strings.TrimSpace(item.UserFullName) != "" {
|
||||||
|
username = strings.TrimSpace(item.UserFullName)
|
||||||
|
}
|
||||||
|
|
||||||
results = append(results, map[string]interface{}{
|
results = append(results, map[string]interface{}{
|
||||||
"name": fmt.Sprintf("<img class='ui avatar image' src='%s'><strong>%s</strong> %s %s",
|
"name": fmt.Sprintf("<img class='ui avatar image' src='%s'><strong>%s</strong> %s %s",
|
||||||
html.EscapeString(item.UserAvatarLink), html.EscapeString(item.UserName), actionText, timeSinceText),
|
html.EscapeString(item.UserAvatarLink), html.EscapeString(username), actionText, timeSinceText),
|
||||||
"value": item.HistoryID,
|
"value": item.HistoryID,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,12 +93,12 @@
|
||||||
<span class="ui text mr-3">{{.i18n.Tr "repo.commits.signed_by_untrusted_user_unmatched"}}:</span>
|
<span class="ui text mr-3">{{.i18n.Tr "repo.commits.signed_by_untrusted_user_unmatched"}}:</span>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{avatar .Verification.SigningUser 28}}
|
{{avatar .Verification.SigningUser 28}}
|
||||||
<a href="{{.Verification.SigningUser.HomeLink}}"><strong>{{.Verification.SigningUser.Name}}</strong></a>
|
<a href="{{.Verification.SigningUser.HomeLink}}"><strong>{{.Verification.SigningUser.GetDisplayName}}</strong></a>
|
||||||
{{else}}
|
{{else}}
|
||||||
<span title="{{.i18n.Tr "gpg.default_key"}}">{{svg "gitea-lock-cog"}}</span>
|
<span title="{{.i18n.Tr "gpg.default_key"}}">{{svg "gitea-lock-cog"}}</span>
|
||||||
<span class="ui text">{{.i18n.Tr "repo.commits.signed_by"}}:</span>
|
<span class="ui text">{{.i18n.Tr "repo.commits.signed_by"}}:</span>
|
||||||
{{avatarByEmail .Verification.SigningEmail "" 28}}
|
{{avatarByEmail .Verification.SigningEmail "" 28}}
|
||||||
<strong>{{.Verification.SigningUser.Name}}</strong>
|
<strong>{{.Verification.SigningUser.GetDisplayName}}</strong>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{svg "gitea-unlock" 16 "mr-3"}}
|
{{svg "gitea-unlock" 16 "mr-3"}}
|
||||||
|
|
Loading…
Reference in a new issue