aboutsummaryrefslogtreecommitdiff
path: root/internal/route/repo
diff options
context:
space:
mode:
Diffstat (limited to 'internal/route/repo')
-rw-r--r--internal/route/repo/commit.go10
-rw-r--r--internal/route/repo/view.go2
2 files changed, 10 insertions, 2 deletions
diff --git a/internal/route/repo/commit.go b/internal/route/repo/commit.go
index 3e09bd06..da8c5e48 100644
--- a/internal/route/repo/commit.go
+++ b/internal/route/repo/commit.go
@@ -5,6 +5,7 @@
package repo
import (
+ gocontext "context"
"path"
"time"
@@ -110,6 +111,13 @@ func FileHistory(c *context.Context) {
renderCommits(c, c.Repo.TreePath)
}
+// tryGetUserByEmail returns a non-nil value if the email is corresponding to an
+// existing user.
+func tryGetUserByEmail(ctx gocontext.Context, email string) *db.User {
+ user, _ := db.Users.GetByEmail(ctx, email)
+ return user
+}
+
func Diff(c *context.Context) {
c.PageIs("Diff")
c.RequireHighlightJS()
@@ -156,7 +164,7 @@ func Diff(c *context.Context) {
c.Data["IsImageFile"] = commit.IsImageFile
c.Data["IsImageFileByIndex"] = commit.IsImageFileByIndex
c.Data["Commit"] = commit
- c.Data["Author"] = db.ValidateCommitWithEmail(commit)
+ c.Data["Author"] = tryGetUserByEmail(c.Req.Context(), commit.Author.Email)
c.Data["Diff"] = diff
c.Data["Parents"] = parents
c.Data["DiffNotAvailable"] = diff.NumFiles() == 0
diff --git a/internal/route/repo/view.go b/internal/route/repo/view.go
index f4b6a162..ac5ed333 100644
--- a/internal/route/repo/view.go
+++ b/internal/route/repo/view.go
@@ -111,7 +111,7 @@ func renderDirectory(c *context.Context, treeLink string) {
}
}
c.Data["LatestCommit"] = latestCommit
- c.Data["LatestCommitUser"] = db.ValidateCommitWithEmail(latestCommit)
+ c.Data["LatestCommitUser"] = tryGetUserByEmail(c.Req.Context(), latestCommit.Author.Email)
if c.Repo.CanEnableEditor() {
c.Data["CanAddFile"] = true