diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2019-09-25 01:39:50 +0800 |
---|---|---|
committer | techknowlogick <techknowlogick@gitea.io> | 2019-09-24 13:39:50 -0400 |
commit | 061388379aae8fa5edc2b41a53512f17adc7a672 (patch) | |
tree | 8f866f552d99374a5c9bb54da0b4f9aa18b59254 /routers | |
parent | 3dd1cee331b8d0beb84e2f92481183520939213a (diff) | |
download | gitea-061388379aae8fa5edc2b41a53512f17adc7a672.tar.gz gitea-061388379aae8fa5edc2b41a53512f17adc7a672.zip |
Move create issue comment to comments package (#8212)
* move create issue comment to comments package
* extract actions on update/delete comment from models to comment service
* fix lint
* fix lint
Diffstat (limited to 'routers')
-rw-r--r-- | routers/api/v1/repo/issue_comment.go | 7 | ||||
-rw-r--r-- | routers/repo/issue.go | 7 |
2 files changed, 8 insertions, 6 deletions
diff --git a/routers/api/v1/repo/issue_comment.go b/routers/api/v1/repo/issue_comment.go index 18fa1d3eb2..60796031a5 100644 --- a/routers/api/v1/repo/issue_comment.go +++ b/routers/api/v1/repo/issue_comment.go @@ -12,6 +12,7 @@ import ( "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/notification" api "code.gitea.io/gitea/modules/structs" + comment_service "code.gitea.io/gitea/services/comments" ) // ListIssueComments list all the comments of an issue @@ -189,7 +190,7 @@ func CreateIssueComment(ctx *context.APIContext, form api.CreateIssueCommentOpti return } - comment, err := models.CreateIssueComment(ctx.User, ctx.Repo.Repository, issue, form.Body, nil) + comment, err := comment_service.CreateIssueComment(ctx.User, ctx.Repo.Repository, issue, form.Body, nil) if err != nil { ctx.Error(500, "CreateIssueComment", err) return @@ -299,7 +300,7 @@ func editIssueComment(ctx *context.APIContext, form api.EditIssueCommentOption) oldContent := comment.Content comment.Content = form.Body - if err := models.UpdateComment(ctx.User, comment, oldContent); err != nil { + if err := comment_service.UpdateComment(comment, ctx.User, oldContent); err != nil { ctx.Error(500, "UpdateComment", err) return } @@ -390,7 +391,7 @@ func deleteIssueComment(ctx *context.APIContext) { return } - if err = models.DeleteComment(ctx.User, comment); err != nil { + if err = comment_service.DeleteComment(comment, ctx.User); err != nil { ctx.Error(500, "DeleteCommentByID", err) return } diff --git a/routers/repo/issue.go b/routers/repo/issue.go index b9083e20e9..1be0b408a6 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -26,6 +26,7 @@ import ( "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/util" + comment_service "code.gitea.io/gitea/services/comments" milestone_service "code.gitea.io/gitea/services/milestone" "github.com/unknwon/com" @@ -1299,7 +1300,7 @@ func NewComment(ctx *context.Context, form auth.CreateCommentForm) { return } - comment, err := models.CreateIssueComment(ctx.User, ctx.Repo.Repository, issue, form.Content, attachments) + comment, err := comment_service.CreateIssueComment(ctx.User, ctx.Repo.Repository, issue, form.Content, attachments) if err != nil { ctx.ServerError("CreateIssueComment", err) return @@ -1339,7 +1340,7 @@ func UpdateCommentContent(ctx *context.Context) { }) return } - if err = models.UpdateComment(ctx.User, comment, oldContent); err != nil { + if err = comment_service.UpdateComment(comment, ctx.User, oldContent); err != nil { ctx.ServerError("UpdateComment", err) return } @@ -1372,7 +1373,7 @@ func DeleteComment(ctx *context.Context) { return } - if err = models.DeleteComment(ctx.User, comment); err != nil { + if err = models.DeleteComment(comment, ctx.User); err != nil { ctx.ServerError("DeleteCommentByID", err) return } |