mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Batch of mirror fixes
This commit is contained in:
@@ -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
|
||||
|
@@ -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))
|
||||
}
|
||||
|
Reference in New Issue
Block a user