From d72c26c08c8bd858a1fcde79a8475dde928c2ba9 Mon Sep 17 00:00:00 2001 From: qwerty287 <80460567+qwerty287@users.noreply.github.com> Date: Fri, 8 Nov 2024 15:05:17 +0200 Subject: [PATCH 1/2] Use repo user to fetch branches (#4339) --- server/api/repo.go | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/server/api/repo.go b/server/api/repo.go index 8d4d9d5f0..77ff27b61 100644 --- a/server/api/repo.go +++ b/server/api/repo.go @@ -362,7 +362,6 @@ func GetRepoPermissions(c *gin.Context) { func GetRepoBranches(c *gin.Context) { _store := store.FromContext(c) repo := session.Repo(c) - user := session.User(c) _forge, err := server.Config.Services.Manager.ForgeFromRepo(repo) if err != nil { log.Error().Err(err).Msg("Cannot get forge from repo") @@ -370,9 +369,15 @@ func GetRepoBranches(c *gin.Context) { return } - forge.Refresh(c, _forge, _store, user) + repoUser, err := _store.GetUser(repo.UserID) + if err != nil { + handleDBError(c, err) + return + } - branches, err := _forge.Branches(c, user, repo, session.Pagination(c)) + forge.Refresh(c, _forge, _store, repoUser) + + branches, err := _forge.Branches(c, repoUser, repo, session.Pagination(c)) if err != nil { log.Error().Err(err).Msg("failed to load branches") c.String(http.StatusInternalServerError, "failed to load branches: %s", err) @@ -396,7 +401,6 @@ func GetRepoBranches(c *gin.Context) { func GetRepoPullRequests(c *gin.Context) { _store := store.FromContext(c) repo := session.Repo(c) - user := session.User(c) _forge, err := server.Config.Services.Manager.ForgeFromRepo(repo) if err != nil { log.Error().Err(err).Msg("Cannot get forge from repo") @@ -404,9 +408,15 @@ func GetRepoPullRequests(c *gin.Context) { return } - forge.Refresh(c, _forge, _store, user) + repoUser, err := _store.GetUser(repo.UserID) + if err != nil { + handleDBError(c, err) + return + } - prs, err := _forge.PullRequests(c, user, repo, session.Pagination(c)) + forge.Refresh(c, _forge, _store, repoUser) + + prs, err := _forge.PullRequests(c, repoUser, repo, session.Pagination(c)) if err != nil { _ = c.AbortWithError(http.StatusInternalServerError, err) return From 066926f952d0c5d217236f3ed68f1751c434b20c Mon Sep 17 00:00:00 2001 From: qwerty287 <80460567+qwerty287@users.noreply.github.com> Date: Sat, 9 Nov 2024 08:23:26 +0200 Subject: [PATCH 2/2] Fix avatar column type (#4340) --- server/model/pipeline.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/model/pipeline.go b/server/model/pipeline.go index a073ad15f..9af629f30 100644 --- a/server/model/pipeline.go +++ b/server/model/pipeline.go @@ -42,8 +42,8 @@ type Pipeline struct { Message string `json:"message" xorm:"TEXT 'message'"` Timestamp int64 `json:"timestamp" xorm:"'timestamp'"` Sender string `json:"sender" xorm:"sender"` // uses reported user for webhooks and name of cron for cron pipelines - Avatar string `json:"author_avatar" xorm:"avatar"` - Email string `json:"author_email" xorm:"email"` + Avatar string `json:"author_avatar" xorm:"varchar(500) avatar"` + Email string `json:"author_email" xorm:"varchar(500) email"` ForgeURL string `json:"forge_url" xorm:"forge_url"` Reviewer string `json:"reviewed_by" xorm:"reviewer"` Reviewed int64 `json:"reviewed" xorm:"reviewed"`