diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2023-11-26 01:21:21 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-25 17:21:21 +0000 |
commit | 882e5023270ed844a4b2911e555e82fe905869e4 (patch) | |
tree | 4d0d28ccf485e123ea7cbe719e7a414065ffba17 /models/repo | |
parent | 80217cacfc3fcf0ffa0dc203843c11e318f85d19 (diff) | |
download | gitea-882e5023270ed844a4b2911e555e82fe905869e4.tar.gz gitea-882e5023270ed844a4b2911e555e82fe905869e4.zip |
Fix comment permissions (#28213)
This PR will fix some missed checks for private repositories' data on
web routes and API routes.
Diffstat (limited to 'models/repo')
-rw-r--r-- | models/repo/release.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/models/repo/release.go b/models/repo/release.go index ff31ec4510..223d3f2501 100644 --- a/models/repo/release.go +++ b/models/repo/release.go @@ -207,6 +207,21 @@ func GetReleaseByID(ctx context.Context, id int64) (*Release, error) { return rel, nil } +// GetReleaseForRepoByID returns release with given ID. +func GetReleaseForRepoByID(ctx context.Context, repoID, id int64) (*Release, error) { + rel := new(Release) + has, err := db.GetEngine(ctx). + Where("id=? AND repo_id=?", id, repoID). + Get(rel) + if err != nil { + return nil, err + } else if !has { + return nil, ErrReleaseNotExist{id, ""} + } + + return rel, nil +} + // FindReleasesOptions describes the conditions to Find releases type FindReleasesOptions struct { db.ListOptions |