aboutsummaryrefslogtreecommitdiff
path: root/routers
diff options
context:
space:
mode:
Diffstat (limited to 'routers')
-rw-r--r--routers/admin/admin.go29
-rw-r--r--routers/repo/issue.go34
2 files changed, 62 insertions, 1 deletions
diff --git a/routers/admin/admin.go b/routers/admin/admin.go
index 96721bfd..91002788 100644
--- a/routers/admin/admin.go
+++ b/routers/admin/admin.go
@@ -98,9 +98,36 @@ func updateSystemStatus() {
sysStatus.NumGC = m.NumGC
}
+// Operation types.
+const (
+ OT_CLEAN_OAUTH = iota + 1
+)
+
func Dashboard(ctx *middleware.Context) {
ctx.Data["Title"] = "Admin Dashboard"
ctx.Data["PageIsDashboard"] = true
+
+ // Run operation.
+ op, _ := base.StrTo(ctx.Query("op")).Int()
+ if op > 0 {
+ var err error
+ var success string
+
+ switch op {
+ case OT_CLEAN_OAUTH:
+ success = "All unbind OAuthes have been deleted."
+ err = models.CleanUnbindOauth()
+ }
+
+ if err != nil {
+ ctx.Flash.Error(err.Error())
+ } else {
+ ctx.Flash.Success(success)
+ }
+ ctx.Redirect("/admin")
+ return
+ }
+
ctx.Data["Stats"] = models.GetStatistic()
updateSystemStatus()
ctx.Data["SysStatus"] = sysStatus
@@ -153,7 +180,7 @@ func Config(ctx *middleware.Context) {
ctx.Data["AppUrl"] = base.AppUrl
ctx.Data["Domain"] = base.Domain
ctx.Data["OfflineMode"] = base.OfflineMode
- ctx.Data["RouterLog"] = base.RouterLog
+ ctx.Data["DisableRouterLog"] = base.DisableRouterLog
ctx.Data["RunUser"] = base.RunUser
ctx.Data["RunMode"] = strings.Title(martini.Env)
ctx.Data["RepoRootPath"] = base.RepoRootPath
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index 4e207662..2bd2f33a 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))
}