0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-05-16 08:17:45 +02: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)) result := make([]*api.TrackedTime, 0, len(tl))
permCache := make(map[int64]access_model.Permission) permCache := make(map[int64]access_model.Permission)
for _, t := range tl { for _, t := range tl {
if t.Issue != nil { // If the issue is not loaded, conservatively skip this entry to avoid bypassing permission checks.
if err := t.Issue.LoadRepo(ctx); err != nil { if t.Issue == nil {
continue continue
} }
perm, ok := permCache[t.Issue.RepoID] if err := t.Issue.LoadRepo(ctx); err != nil {
if !ok { continue
var err error }
perm, err = access_model.GetUserRepoPermission(ctx, t.Issue.Repo, doer) perm, ok := permCache[t.Issue.RepoID]
if err != nil { if !ok {
continue var err error
} perm, err = access_model.GetUserRepoPermission(ctx, t.Issue.Repo, doer)
permCache[t.Issue.RepoID] = perm if err != nil {
}
if !perm.CanReadIssuesOrPulls(t.Issue.IsPull) {
continue continue
} }
permCache[t.Issue.RepoID] = perm
}
if !perm.CanReadIssuesOrPulls(t.Issue.IsPull) {
continue
} }
result = append(result, ToTrackedTime(ctx, doer, t)) result = append(result, ToTrackedTime(ctx, doer, t))
} }