mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-05 10:26:15 +02:00
fix abuses
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,7 +329,7 @@ func GetLatestPackageVersion(ctx *context.APIContext) {
|
||||
return
|
||||
}
|
||||
if len(pvs) == 0 {
|
||||
ctx.APIError(http.StatusNotFound, err.Error())
|
||||
ctx.APIErrorNotFound()
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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...)
|
||||
|
||||
Reference in New Issue
Block a user