[BUG] Return blocking errors as JSON errors

- These endspoints are since b71cb7acdc
JSON-based and should therefore return JSON errors.
- Integration tests adjusted.

(cherry picked from commit d97cf0e854)
This commit is contained in:
Gusted 2024-08-09 20:33:23 +02:00 committed by forgejo-backport-action
parent 29afb54daf
commit e988d1a8bb
3 changed files with 46 additions and 20 deletions

View file

@ -1512,8 +1512,7 @@ func CompareAndPullRequestPost(ctx *context.Context) {
if err := pull_service.NewPullRequest(ctx, repo, pullIssue, labelIDs, attachments, pullRequest, assigneeIDs); err != nil {
if errors.Is(err, user_model.ErrBlockedByUser) {
ctx.Flash.Error(ctx.Tr("repo.pulls.blocked_by_user"))
ctx.Redirect(ctx.Link)
ctx.JSONError(ctx.Tr("repo.pulls.blocked_by_user"))
return
} else if repo_model.IsErrUserDoesNotHaveAccessToRepo(err) {
ctx.Error(http.StatusBadRequest, "UserDoesNotHaveAccessToRepo", err.Error())