diff options
author | Unknown <joe2010xtmf@163.com> | 2014-05-06 13:47:47 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-05-06 13:47:47 -0400 |
commit | 7cb5a15c9b7a2a118d756d15cb745743f207a318 (patch) | |
tree | dba01566116b8ad49f0762812ecb3ab96597090f /routers/repo/issue.go | |
parent | e573855a4f040abd4aa6a2afa9ce610a1ec2670f (diff) | |
download | gitea-7cb5a15c9b7a2a118d756d15cb745743f207a318.tar.gz gitea-7cb5a15c9b7a2a118d756d15cb745743f207a318.zip |
Batch of mirror fixes
Diffstat (limited to 'routers/repo/issue.go')
-rw-r--r-- | routers/repo/issue.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 4e2076620d..2bd2f33a1b 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -295,5 +295,39 @@ func Comment(ctx *middleware.Context, params martini.Params) { } } + // Notify watchers. + if err = models.NotifyWatchers(&models.Action{ActUserId: ctx.User.Id, ActUserName: ctx.User.Name, ActEmail: ctx.User.Email, + OpType: models.OP_COMMENT_ISSUE, Content: fmt.Sprintf("%d|%s", issue.Index, strings.Split(content, "\n")[0]), + RepoId: ctx.Repo.Repository.Id, RepoName: ctx.Repo.Repository.Name, RefName: ""}); err != nil { + ctx.Handle(500, "issue.CreateIssue(NotifyWatchers)", err) + return + } + + // Mail watchers and mentions. + if base.Service.NotifyMail { + issue.Content = content + tos, err := mailer.SendIssueNotifyMail(ctx.User, ctx.Repo.Owner, ctx.Repo.Repository, issue) + if err != nil { + ctx.Handle(500, "issue.Comment(SendIssueNotifyMail)", err) + return + } + + tos = append(tos, ctx.User.LowerName) + ms := base.MentionPattern.FindAllString(issue.Content, -1) + newTos := make([]string, 0, len(ms)) + for _, m := range ms { + if com.IsSliceContainsStr(tos, m[1:]) { + continue + } + + newTos = append(newTos, m[1:]) + } + if err = mailer.SendIssueMentionMail(ctx.Render, ctx.User, ctx.Repo.Owner, + ctx.Repo.Repository, issue, models.GetUserEmailsByNames(newTos)); err != nil { + ctx.Handle(500, "issue.Comment(SendIssueMentionMail)", err) + return + } + } + ctx.Redirect(fmt.Sprintf("%s/issues/%d", ctx.Repo.RepoLink, index)) } |