diff options
Diffstat (limited to 'routers/repo/issue.go')
-rw-r--r-- | routers/repo/issue.go | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 3cce483062..3bcfdf1b04 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -490,7 +490,7 @@ func NewIssuePost(ctx *context.Context, form auth.CreateIssueForm) { return } - notification.Service.NotifyIssue(issue, ctx.User.ID) + notification.NotifyNewIssue(issue) log.Trace("Issue created: %d/%d", repo.ID, issue.ID) ctx.Redirect(ctx.Repo.RepoLink + "/issues/" + com.ToStr(issue.Index)) @@ -1004,15 +1004,19 @@ func UpdateIssueStatus(ctx *context.Context) { return } for _, issue := range issues { - if err := issue.ChangeStatus(ctx.User, issue.Repo, isClosed); err != nil { - if models.IsErrDependenciesLeft(err) { - ctx.JSON(http.StatusPreconditionFailed, map[string]interface{}{ - "error": "cannot close this issue because it still has open dependencies", - }) + if issue.IsClosed != isClosed { + if err := issue.ChangeStatus(ctx.User, issue.Repo, isClosed); err != nil { + if models.IsErrDependenciesLeft(err) { + ctx.JSON(http.StatusPreconditionFailed, map[string]interface{}{ + "error": "cannot close this issue because it still has open dependencies", + }) + return + } + ctx.ServerError("ChangeStatus", err) return } - ctx.ServerError("ChangeStatus", err) - return + + notification.NotifyIssueChangeStatus(ctx.User, issue, isClosed) } } ctx.JSON(200, map[string]interface{}{ @@ -1072,7 +1076,8 @@ func NewComment(ctx *context.Context, form auth.CreateCommentForm) { if pr != nil { ctx.Flash.Info(ctx.Tr("repo.pulls.open_unmerged_pull_exists", pr.Index)) } else { - if err := issue.ChangeStatus(ctx.User, ctx.Repo.Repository, form.Status == "close"); err != nil { + isClosed := form.Status == "close" + if err := issue.ChangeStatus(ctx.User, ctx.Repo.Repository, isClosed); err != nil { log.Error(4, "ChangeStatus: %v", err) if models.IsErrDependenciesLeft(err) { @@ -1088,7 +1093,7 @@ func NewComment(ctx *context.Context, form auth.CreateCommentForm) { } else { log.Trace("Issue [%d] status changed to closed: %v", issue.ID, issue.IsClosed) - notification.Service.NotifyIssue(issue, ctx.User.ID) + notification.NotifyIssueChangeStatus(ctx.User, issue, isClosed) } } } @@ -1116,7 +1121,7 @@ func NewComment(ctx *context.Context, form auth.CreateCommentForm) { return } - notification.Service.NotifyIssue(issue, ctx.User.ID) + notification.NotifyCreateIssueComment(ctx.User, ctx.Repo.Repository, issue, comment) log.Trace("Comment created: %d/%d/%d", ctx.Repo.Repository.ID, issue.ID, comment.ID) } |