fix abuses

This commit is contained in:
wxiaoguang
2026-06-06 20:39:26 +08:00
parent c2957adddb
commit 070118d39b
5 changed files with 9 additions and 9 deletions
+2 -2
View File
@@ -289,7 +289,7 @@ func DeleteUser(ctx *context.APIContext) {
// "$ref": "#/responses/validationError"
if ctx.ContextUser.IsOrganization() {
ctx.APIError(http.StatusUnprocessableEntity, fmt.Sprintf("%s is an organization not a user", ctx.ContextUser.Name))
ctx.APIError(http.StatusUnprocessableEntity, "not an organization")
return
}
@@ -551,7 +551,7 @@ func RenameUser(ctx *context.APIContext) {
// "$ref": "#/responses/validationError"
if ctx.ContextUser.IsOrganization() {
ctx.APIError(http.StatusUnprocessableEntity, fmt.Sprintf("%s is an organization not a user", ctx.ContextUser.Name))
ctx.APIError(http.StatusUnprocessableEntity, "not an organization")
return
}
+2 -2
View File
@@ -734,14 +734,14 @@ func mustEnableWiki(ctx *context.APIContext) {
// FIXME: for consistency, maybe most mustNotBeArchived checks should be replaced with mustEnableEditor
func mustNotBeArchived(ctx *context.APIContext) {
if ctx.Repo.Repository.IsArchived {
ctx.APIError(http.StatusLocked, fmt.Sprintf("%s is archived", ctx.Repo.Repository.FullName()))
ctx.APIError(http.StatusLocked, "repo is archived")
return
}
}
func mustEnableEditor(ctx *context.APIContext) {
if !ctx.Repo.Repository.CanEnableEditor() {
ctx.APIError(http.StatusLocked, fmt.Sprintf("%s is not allowed to edit", ctx.Repo.Repository.FullName()))
ctx.APIError(http.StatusLocked, "repo is not allowed to edit")
return
}
}
+1 -1
View File
@@ -329,7 +329,7 @@ func GetLatestPackageVersion(ctx *context.APIContext) {
return
}
if len(pvs) == 0 {
ctx.APIError(http.StatusNotFound, err.Error())
ctx.APIErrorNotFound()
return
}
+2 -2
View File
@@ -1230,7 +1230,7 @@ func UpdatePullRequest(ctx *context.APIContext) {
}
if pr.HasMerged {
ctx.APIError(http.StatusUnprocessableEntity, err.Error())
ctx.APIError(http.StatusUnprocessableEntity, "pull request is already merged")
return
}
@@ -1240,7 +1240,7 @@ func UpdatePullRequest(ctx *context.APIContext) {
}
if pr.Issue.IsClosed {
ctx.APIError(http.StatusUnprocessableEntity, err.Error())
ctx.APIError(http.StatusUnprocessableEntity, "pull request is already closed")
return
}
+2 -2
View File
@@ -53,7 +53,7 @@ func ListJobs(ctx *context.APIContext, ownerID, repoID, runID int64, runAttemptI
for _, status := range ctx.FormStrings("status") {
values, err := convertToInternal(status)
if err != nil {
ctx.APIError(http.StatusBadRequest, fmt.Sprintf("Invalid status %s", status))
ctx.APIError(http.StatusBadRequest, "invalid status")
return
}
opts.Statuses = append(opts.Statuses, values...)
@@ -155,7 +155,7 @@ func ListRuns(ctx *context.APIContext, ownerID, repoID int64) {
for _, status := range ctx.FormStrings("status") {
values, err := convertToInternal(status)
if err != nil {
ctx.APIError(http.StatusBadRequest, fmt.Sprintf("Invalid status %s", status))
ctx.APIError(http.StatusBadRequest, "invalid status")
return
}
opts.Status = append(opts.Status, values...)