aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/v1/packages
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2022-05-07 18:21:15 +0200
committerGitHub <noreply@github.com>2022-05-07 18:21:15 +0200
commit8adba93498ccdde7edcb54e10f6a3d176c3815c4 (patch)
treee48b5809a0a76ca8c2087d373d00a225b713ebb3 /routers/api/v1/packages
parent38d72d40f132df8a6e90063f3e96a80048bf299e (diff)
downloadgitea-8adba93498ccdde7edcb54e10f6a3d176c3815c4.tar.gz
gitea-8adba93498ccdde7edcb54e10f6a3d176c3815c4.zip
Hide private repositories in packages (#19584)
Diffstat (limited to 'routers/api/v1/packages')
-rw-r--r--routers/api/v1/packages/package.go15
1 files changed, 13 insertions, 2 deletions
diff --git a/routers/api/v1/packages/package.go b/routers/api/v1/packages/package.go
index f3aa19c319..038924737a 100644
--- a/routers/api/v1/packages/package.go
+++ b/routers/api/v1/packages/package.go
@@ -73,7 +73,12 @@ func ListPackages(ctx *context.APIContext) {
apiPackages := make([]*api.Package, 0, len(pds))
for _, pd := range pds {
- apiPackages = append(apiPackages, convert.ToPackage(pd))
+ apiPackage, err := convert.ToPackage(ctx, pd, ctx.Doer)
+ if err != nil {
+ ctx.Error(http.StatusInternalServerError, "Error converting package for api", err)
+ return
+ }
+ apiPackages = append(apiPackages, apiPackage)
}
ctx.SetLinkHeader(int(count), listOptions.PageSize)
@@ -115,7 +120,13 @@ func GetPackage(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- ctx.JSON(http.StatusOK, convert.ToPackage(ctx.Package.Descriptor))
+ apiPackage, err := convert.ToPackage(ctx, ctx.Package.Descriptor, ctx.Doer)
+ if err != nil {
+ ctx.Error(http.StatusInternalServerError, "Error converting package for api", err)
+ return
+ }
+
+ ctx.JSON(http.StatusOK, apiPackage)
}
// DeletePackage deletes a package