diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2019-10-29 00:45:43 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-29 00:45:43 +0800 |
commit | af8957bc4ce78613fe03cb1abc6c961dd67ff344 (patch) | |
tree | b17b15eddca01c46d53d38abf184a2450e557de4 /routers | |
parent | e3875ace913ca428804acc9a9ee1cd0b06cd8026 (diff) | |
download | gitea-af8957bc4ce78613fe03cb1abc6c961dd67ff344.tar.gz gitea-af8957bc4ce78613fe03cb1abc6c961dd67ff344.zip |
Move issue notifications (#8713)
Diffstat (limited to 'routers')
-rw-r--r-- | routers/api/v1/repo/issue.go | 10 | ||||
-rw-r--r-- | routers/api/v1/repo/pull.go | 7 | ||||
-rw-r--r-- | routers/repo/issue.go | 9 | ||||
-rw-r--r-- | routers/repo/pull.go | 8 |
4 files changed, 4 insertions, 30 deletions
diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go index 09a4e32d2f..426826653c 100644 --- a/routers/api/v1/repo/issue.go +++ b/routers/api/v1/repo/issue.go @@ -14,7 +14,6 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" issue_indexer "code.gitea.io/gitea/modules/indexer/issues" - "code.gitea.io/gitea/modules/notification" "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/timeutil" @@ -237,7 +236,7 @@ func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) { form.Labels = make([]int64, 0) } - if err := issue_service.NewIssue(ctx.Repo.Repository, issue, form.Labels, nil); err != nil { + if err := issue_service.NewIssue(ctx.Repo.Repository, issue, form.Labels, nil, assigneeIDs); err != nil { if models.IsErrUserDoesNotHaveAccessToRepo(err) { ctx.Error(400, "UserDoesNotHaveAccessToRepo", err) return @@ -246,13 +245,6 @@ func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) { return } - if err := issue_service.AddAssignees(issue, ctx.User, assigneeIDs); err != nil { - ctx.ServerError("AddAssignees", err) - return - } - - notification.NotifyNewIssue(issue) - if form.Closed { if err := issue_service.ChangeStatus(issue, ctx.User, true); err != nil { if models.IsErrDependenciesLeft(err) { diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go index d4ce00fa12..0180aebf89 100644 --- a/routers/api/v1/repo/pull.go +++ b/routers/api/v1/repo/pull.go @@ -305,7 +305,7 @@ func CreatePullRequest(ctx *context.APIContext, form api.CreatePullRequestOption } } - if err := pull_service.NewPullRequest(repo, prIssue, labelIDs, []string{}, pr, patch); err != nil { + if err := pull_service.NewPullRequest(repo, prIssue, labelIDs, []string{}, pr, patch, assigneeIDs); err != nil { if models.IsErrUserDoesNotHaveAccessToRepo(err) { ctx.Error(400, "UserDoesNotHaveAccessToRepo", err) return @@ -317,11 +317,6 @@ func CreatePullRequest(ctx *context.APIContext, form api.CreatePullRequestOption return } - if err := issue_service.AddAssignees(prIssue, ctx.User, assigneeIDs); err != nil { - ctx.ServerError("AddAssignees", err) - return - } - notification.NotifyNewPullRequest(pr) log.Trace("Pull request created: %d/%d", repo.ID, prIssue.ID) diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 9c313e56d4..12ff0a054c 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -574,7 +574,7 @@ func NewIssuePost(ctx *context.Context, form auth.CreateIssueForm) { Content: form.Content, Ref: form.Ref, } - if err := issue_service.NewIssue(repo, issue, labelIDs, attachments); err != nil { + if err := issue_service.NewIssue(repo, issue, labelIDs, attachments, assigneeIDs); err != nil { if models.IsErrUserDoesNotHaveAccessToRepo(err) { ctx.Error(400, "UserDoesNotHaveAccessToRepo", err.Error()) return @@ -583,13 +583,6 @@ func NewIssuePost(ctx *context.Context, form auth.CreateIssueForm) { return } - if err := issue_service.AddAssignees(issue, ctx.User, assigneeIDs); err != nil { - log.Error("AddAssignees: %v", err) - ctx.Flash.Error(ctx.Tr("issues.assignee.error")) - } - - notification.NotifyNewIssue(issue) - log.Trace("Issue created: %d/%d", repo.ID, issue.ID) ctx.Redirect(ctx.Repo.RepoLink + "/issues/" + com.ToStr(issue.Index)) } diff --git a/routers/repo/pull.go b/routers/repo/pull.go index f3a9aca2a4..3defd04b1b 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -24,7 +24,6 @@ import ( "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/services/gitdiff" - issue_service "code.gitea.io/gitea/services/issue" pull_service "code.gitea.io/gitea/services/pull" repo_service "code.gitea.io/gitea/services/repository" @@ -772,7 +771,7 @@ func CompareAndPullRequestPost(ctx *context.Context, form auth.CreateIssueForm) // FIXME: check error in the case two people send pull request at almost same time, give nice error prompt // instead of 500. - if err := pull_service.NewPullRequest(repo, pullIssue, labelIDs, attachments, pullRequest, patch); err != nil { + if err := pull_service.NewPullRequest(repo, pullIssue, labelIDs, attachments, pullRequest, patch, assigneeIDs); err != nil { if models.IsErrUserDoesNotHaveAccessToRepo(err) { ctx.Error(400, "UserDoesNotHaveAccessToRepo", err.Error()) return @@ -784,11 +783,6 @@ func CompareAndPullRequestPost(ctx *context.Context, form auth.CreateIssueForm) return } - if err := issue_service.AddAssignees(pullIssue, ctx.User, assigneeIDs); err != nil { - log.Error("AddAssignees: %v", err) - ctx.Flash.Error(ctx.Tr("issues.assignee.error")) - } - notification.NotifyNewPullRequest(pullRequest) log.Trace("Pull request created: %d/%d", repo.ID, pullIssue.ID) |