Extract actions on new issue from models to services (#8217)
* extract actions on new issue from models to services * improve code * rename services/issues to services/issue
This commit is contained in:
parent
a5992d1725
commit
e6113000c5
4 changed files with 51 additions and 27 deletions
|
@ -19,6 +19,7 @@ import (
|
|||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
issue_service "code.gitea.io/gitea/services/issue"
|
||||
milestone_service "code.gitea.io/gitea/services/milestone"
|
||||
)
|
||||
|
||||
|
@ -217,7 +218,7 @@ func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) {
|
|||
form.Labels = make([]int64, 0)
|
||||
}
|
||||
|
||||
if err := models.NewIssue(ctx.Repo.Repository, issue, form.Labels, assigneeIDs, nil); err != nil {
|
||||
if err := issue_service.NewIssue(ctx.Repo.Repository, issue, form.Labels, assigneeIDs, nil); err != nil {
|
||||
if models.IsErrUserDoesNotHaveAccessToRepo(err) {
|
||||
ctx.Error(400, "UserDoesNotHaveAccessToRepo", err)
|
||||
return
|
||||
|
|
|
@ -27,6 +27,7 @@ import (
|
|||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
comment_service "code.gitea.io/gitea/services/comments"
|
||||
issue_service "code.gitea.io/gitea/services/issue"
|
||||
milestone_service "code.gitea.io/gitea/services/milestone"
|
||||
|
||||
"github.com/unknwon/com"
|
||||
|
@ -571,7 +572,7 @@ func NewIssuePost(ctx *context.Context, form auth.CreateIssueForm) {
|
|||
Content: form.Content,
|
||||
Ref: form.Ref,
|
||||
}
|
||||
if err := models.NewIssue(repo, issue, labelIDs, assigneeIDs, attachments); err != nil {
|
||||
if err := issue_service.NewIssue(repo, issue, labelIDs, assigneeIDs, attachments); err != nil {
|
||||
if models.IsErrUserDoesNotHaveAccessToRepo(err) {
|
||||
ctx.Error(400, "UserDoesNotHaveAccessToRepo", err.Error())
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue