From d40c8e1b854d93bea239ba34a5b4b1a9f84ad688 Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Sat, 30 May 2026 15:56:54 -0500 Subject: [PATCH 1/2] fix(api): fix compilation errors in license key API handlers Replace ctx.Bind/ctx.APIErrorValidation (which don't exist on APIContext) with web.GetForm() pattern used by all other API handlers. Co-Authored-By: Claude Opus 4.6 (1M context) --- routers/api/v1/repo/license_key.go | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/routers/api/v1/repo/license_key.go b/routers/api/v1/repo/license_key.go index 50da14d4f8..5fcd734616 100644 --- a/routers/api/v1/repo/license_key.go +++ b/routers/api/v1/repo/license_key.go @@ -10,6 +10,7 @@ import ( "git.mokoconsulting.tech/MokoConsulting/MokoGitea/models/licenses" "git.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/structs" "git.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/timeutil" + "git.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/web" "git.mokoconsulting.tech/MokoConsulting/MokoGitea/services/context" ) @@ -71,11 +72,7 @@ func ListLicensePackages(ctx *context.APIContext) { // CreateLicensePackage creates a new license package. func CreateLicensePackage(ctx *context.APIContext) { - form := &structs.CreateLicensePackageOption{} - if err := ctx.Bind(form); err != nil { - ctx.APIErrorValidation(err) - return - } + form := web.GetForm(ctx).(*structs.CreateLicensePackageOption) pkg := &licenses.LicensePackage{ OwnerID: ctx.Repo.Repository.OwnerID, @@ -115,11 +112,7 @@ func ListLicenseKeys(ctx *context.APIContext) { // CreateLicenseKey creates a new license key. func CreateLicenseKey(ctx *context.APIContext) { - form := &structs.CreateLicenseKeyOption{} - if err := ctx.Bind(form); err != nil { - ctx.APIErrorValidation(err) - return - } + form := web.GetForm(ctx).(*structs.CreateLicenseKeyOption) key := &licenses.LicenseKey{ PackageID: form.PackageID, -- 2.52.0 From 470364e50c713247137b95f18f4d9d99efd0f87d Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Sat, 30 May 2026 16:42:22 -0500 Subject: [PATCH 2/2] =?UTF-8?q?fix(api):=20fix=20route=20registration=20?= =?UTF-8?q?=E2=80=94=20reqAdmin=20and=20m.Delete=20pattern?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix two compilation errors in license key API routes: - reqRepoAdmin() does not exist, use reqAdmin() instead - m.Delete(handler) needs route pattern: m.Delete("", handler) Co-Authored-By: Claude Opus 4.6 (1M context) --- routers/api/v1/api.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index 59ee6877bc..1df15a7465 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -1350,15 +1350,15 @@ func Routes() *web.Router { m.Group("/license-packages", func() { m.Combo("").Get(repo.ListLicensePackages). Post(bind(api.CreateLicensePackageOption{}), repo.CreateLicensePackage) - }, reqToken(), reqRepoAdmin()) + }, reqToken(), reqAdmin()) m.Group("/license-keys", func() { m.Combo("").Get(repo.ListLicenseKeys). Post(bind(api.CreateLicenseKeyOption{}), repo.CreateLicenseKey) m.Group("/{id}", func() { - m.Delete(repo.DeleteLicenseKey) + m.Delete("", repo.DeleteLicenseKey) m.Get("/usage", repo.GetLicenseKeyUsage) }) - }, reqToken(), reqRepoAdmin()) + }, reqToken(), reqAdmin()) m.Post("/mirror-sync", reqToken(), reqRepoWriter(unit.TypeCode), mustNotBeArchived, repo.MirrorSync) m.Post("/push_mirrors-sync", reqAdmin(), reqToken(), mustNotBeArchived, repo.PushMirrorSync) m.Group("/push_mirrors", func() { -- 2.52.0