diff --git a/routers/web/repo/setting/protected_branch.go b/routers/web/repo/setting/protected_branch.go index 4374e95340a..a5a25e6c4e0 100644 --- a/routers/web/repo/setting/protected_branch.go +++ b/routers/web/repo/setting/protected_branch.go @@ -20,6 +20,7 @@ import ( "code.gitea.io/gitea/models/unit" "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/glob" + "code.gitea.io/gitea/modules/json" "code.gitea.io/gitea/modules/templates" "code.gitea.io/gitea/modules/web" "code.gitea.io/gitea/routers/web/repo" @@ -312,10 +313,14 @@ func DeleteProtectedBranchRulePost(ctx *context.Context) { } func UpdateBranchProtectionPriories(ctx *context.Context) { - form := web.GetForm(ctx).(*forms.ProtectBranchPriorityForm) - repo := ctx.Repo.Repository - - if err := git_model.UpdateProtectBranchPriorities(ctx, repo, form.IDs); err != nil { + var form struct { + IDs []int64 `json:"ids"` + } + if err := json.NewDecoder(ctx.Req.Body).Decode(&form); err != nil { + ctx.JSONError("invalid argument") + return + } + if err := git_model.UpdateProtectBranchPriorities(ctx, ctx.Repo.Repository, form.IDs); err != nil { ctx.ServerError("UpdateProtectBranchPriorities", err) return } diff --git a/routers/web/web.go b/routers/web/web.go index c6dece7b569..ecd75250d24 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -1175,7 +1175,7 @@ func registerWebRoutes(m *web.Router, webAuth *AuthMiddleware) { m.Combo("/edit").Get(repo_setting.SettingsProtectedBranch). Post(web.Bind(forms.ProtectBranchForm{}), context.RepoMustNotBeArchived(), repo_setting.SettingsProtectedBranchPost) m.Post("/{id}/delete", repo_setting.DeleteProtectedBranchRulePost) - m.Post("/priority", web.Bind(forms.ProtectBranchPriorityForm{}), context.RepoMustNotBeArchived(), repo_setting.UpdateBranchProtectionPriories) + m.Post("/priority", context.RepoMustNotBeArchived(), repo_setting.UpdateBranchProtectionPriories) }) m.Group("/tags", func() { diff --git a/services/forms/repo_form.go b/services/forms/repo_form.go index 3135026e36c..d8e019f8609 100644 --- a/services/forms/repo_form.go +++ b/services/forms/repo_form.go @@ -202,10 +202,6 @@ func (f *ProtectBranchForm) Validate(req *http.Request, errs binding.Errors) bin return middleware.Validate(errs, ctx.Data, f, ctx.Locale) } -type ProtectBranchPriorityForm struct { - IDs []int64 -} - // WebhookForm form for changing web hook type WebhookForm struct { Name string `binding:"MaxSize(255)"`