summaryrefslogtreecommitdiffstats
path: root/routers/api/v1/repo/issue_reaction.go
diff options
context:
space:
mode:
Diffstat (limited to 'routers/api/v1/repo/issue_reaction.go')
-rw-r--r--routers/api/v1/repo/issue_reaction.go52
1 files changed, 3 insertions, 49 deletions
diff --git a/routers/api/v1/repo/issue_reaction.go b/routers/api/v1/repo/issue_reaction.go
index b14dc146d9..27edc1abad 100644
--- a/routers/api/v1/repo/issue_reaction.go
+++ b/routers/api/v1/repo/issue_reaction.go
@@ -51,30 +51,7 @@ func GetIssueCommentReactions(ctx *context.APIContext) {
// "404":
// "$ref": "#/responses/notFound"
- comment, err := issues_model.GetCommentByID(ctx, ctx.ParamsInt64(":id"))
- if err != nil {
- if issues_model.IsErrCommentNotExist(err) {
- ctx.NotFound(err)
- } else {
- ctx.Error(http.StatusInternalServerError, "GetCommentByID", err)
- }
- return
- }
-
- if err := comment.LoadIssue(ctx); err != nil {
- ctx.Error(http.StatusInternalServerError, "comment.LoadIssue", err)
- return
- }
-
- if comment.Issue.RepoID != ctx.Repo.Repository.ID {
- ctx.NotFound()
- return
- }
-
- if !ctx.Repo.CanReadIssuesOrPulls(comment.Issue.IsPull) {
- ctx.Error(http.StatusForbidden, "GetIssueCommentReactions", errors.New("no permission to get reactions"))
- return
- }
+ comment := ctx.Comment
reactions, _, err := issues_model.FindCommentReactions(ctx, comment.IssueID, comment.ID)
if err != nil {
@@ -188,30 +165,7 @@ func DeleteIssueCommentReaction(ctx *context.APIContext) {
}
func changeIssueCommentReaction(ctx *context.APIContext, form api.EditReactionOption, isCreateType bool) {
- comment, err := issues_model.GetCommentByID(ctx, ctx.ParamsInt64(":id"))
- if err != nil {
- if issues_model.IsErrCommentNotExist(err) {
- ctx.NotFound(err)
- } else {
- ctx.Error(http.StatusInternalServerError, "GetCommentByID", err)
- }
- return
- }
-
- if err = comment.LoadIssue(ctx); err != nil {
- ctx.Error(http.StatusInternalServerError, "comment.LoadIssue() failed", err)
- return
- }
-
- if comment.Issue.RepoID != ctx.Repo.Repository.ID {
- ctx.NotFound()
- return
- }
-
- if !ctx.Repo.CanReadIssuesOrPulls(comment.Issue.IsPull) {
- ctx.NotFound()
- return
- }
+ comment := ctx.Comment
if comment.Issue.IsLocked && !ctx.Repo.CanWriteIssuesOrPulls(comment.Issue.IsPull) {
ctx.Error(http.StatusForbidden, "ChangeIssueCommentReaction", errors.New("no permission to change reaction"))
@@ -243,7 +197,7 @@ func changeIssueCommentReaction(ctx *context.APIContext, form api.EditReactionOp
})
} else {
// DeleteIssueCommentReaction part
- err = issues_model.DeleteCommentReaction(ctx, ctx.Doer.ID, comment.Issue.ID, comment.ID, form.Reaction)
+ err := issues_model.DeleteCommentReaction(ctx, ctx.Doer.ID, comment.Issue.ID, comment.ID, form.Reaction)
if err != nil {
ctx.Error(http.StatusInternalServerError, "DeleteCommentReaction", err)
return