mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Followup to pinned Issues (#24945)
This addressees some things from #24406 that came up after the PR was merged. Mostly from @delvh. --------- Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: delvh <dev.lh@web.de>
This commit is contained in:
@@ -45,6 +45,8 @@ func PinIssue(ctx *context.APIContext) {
|
||||
if err != nil {
|
||||
if issues_model.IsErrIssueNotExist(err) {
|
||||
ctx.NotFound()
|
||||
} else if issues_model.IsErrIssueMaxPinReached(err) {
|
||||
ctx.Error(http.StatusBadRequest, "MaxPinReached", err)
|
||||
} else {
|
||||
ctx.Error(http.StatusInternalServerError, "GetIssueByIndex", err)
|
||||
}
|
||||
@@ -55,11 +57,13 @@ func PinIssue(ctx *context.APIContext) {
|
||||
err = issue.LoadRepo(ctx)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "LoadRepo", err)
|
||||
return
|
||||
}
|
||||
|
||||
err = issue.Pin(ctx, ctx.Doer)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "PinIssue", err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Status(http.StatusNoContent)
|
||||
@@ -108,11 +112,13 @@ func UnpinIssue(ctx *context.APIContext) {
|
||||
err = issue.LoadRepo(ctx)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "LoadRepo", err)
|
||||
return
|
||||
}
|
||||
|
||||
err = issue.Unpin(ctx, ctx.Doer)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "UnpinIssue", err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Status(http.StatusNoContent)
|
||||
@@ -166,6 +172,7 @@ func MoveIssuePin(ctx *context.APIContext) {
|
||||
err = issue.MovePin(ctx, int(ctx.ParamsInt64(":position")))
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "MovePin", err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Status(http.StatusNoContent)
|
||||
@@ -193,12 +200,12 @@ func ListPinnedIssues(ctx *context.APIContext) {
|
||||
// "200":
|
||||
// "$ref": "#/responses/IssueList"
|
||||
issues, err := issues_model.GetPinnedIssues(ctx, ctx.Repo.Repository.ID, false)
|
||||
|
||||
if err == nil {
|
||||
ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, issues))
|
||||
} else {
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "LoadPinnedIssues", err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, convert.ToAPIIssueList(ctx, issues))
|
||||
}
|
||||
|
||||
// ListPinnedPullRequests returns a list of all pinned PRs
|
||||
@@ -225,6 +232,7 @@ func ListPinnedPullRequests(ctx *context.APIContext) {
|
||||
issues, err := issues_model.GetPinnedIssues(ctx, ctx.Repo.Repository.ID, true)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "LoadPinnedPullRequests", err)
|
||||
return
|
||||
}
|
||||
|
||||
apiPrs := make([]*api.PullRequest, len(issues))
|
||||
|
Reference in New Issue
Block a user