0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-02-22 13:15:23 +01:00

Update services/convert/issue.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
Lunny Xiao 2026-02-19 14:09:53 -08:00 committed by GitHub
parent 9342bc914f
commit 085b892aec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -228,22 +228,24 @@ func ToTrackedTimeList(ctx context.Context, doer *user_model.User, tl issues_mod
result := make([]*api.TrackedTime, 0, len(tl))
permCache := make(map[int64]access_model.Permission)
for _, t := range tl {
if t.Issue != nil {
if err := t.Issue.LoadRepo(ctx); err != nil {
continue
}
perm, ok := permCache[t.Issue.RepoID]
if !ok {
var err error
perm, err = access_model.GetUserRepoPermission(ctx, t.Issue.Repo, doer)
if err != nil {
continue
}
permCache[t.Issue.RepoID] = perm
}
if !perm.CanReadIssuesOrPulls(t.Issue.IsPull) {
// If the issue is not loaded, conservatively skip this entry to avoid bypassing permission checks.
if t.Issue == nil {
continue
}
if err := t.Issue.LoadRepo(ctx); err != nil {
continue
}
perm, ok := permCache[t.Issue.RepoID]
if !ok {
var err error
perm, err = access_model.GetUserRepoPermission(ctx, t.Issue.Repo, doer)
if err != nil {
continue
}
permCache[t.Issue.RepoID] = perm
}
if !perm.CanReadIssuesOrPulls(t.Issue.IsPull) {
continue
}
result = append(result, ToTrackedTime(ctx, doer, t))
}