diff options
Diffstat (limited to 'routers')
-rw-r--r-- | routers/admin/admin.go | 3 | ||||
-rw-r--r-- | routers/admin/users.go | 5 | ||||
-rw-r--r-- | routers/api/v1/admin/user.go | 5 | ||||
-rw-r--r-- | routers/api/v1/repo/issue.go | 4 | ||||
-rw-r--r-- | routers/repo/issue.go | 55 | ||||
-rw-r--r-- | routers/repo/pull.go | 3 | ||||
-rw-r--r-- | routers/repo/setting.go | 6 | ||||
-rw-r--r-- | routers/user/auth.go | 11 | ||||
-rw-r--r-- | routers/user/setting.go | 13 |
9 files changed, 17 insertions, 88 deletions
diff --git a/routers/admin/admin.go b/routers/admin/admin.go index 1608b73b11..bc850b638e 100644 --- a/routers/admin/admin.go +++ b/routers/admin/admin.go @@ -17,7 +17,6 @@ import ( "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/context" "github.com/gogits/gogs/modules/cron" - "github.com/gogits/gogs/modules/mailer" "github.com/gogits/gogs/modules/process" "github.com/gogits/gogs/modules/setting" ) @@ -178,7 +177,7 @@ func Dashboard(ctx *context.Context) { func SendTestMail(ctx *context.Context) { email := ctx.Query("email") // Send a test email to the user's email address and redirect back to Config - if err := mailer.SendTestMail(email); err != nil { + if err := models.SendTestMail(email); err != nil { ctx.Flash.Error(ctx.Tr("admin.config.test_mail_failed", email, err)) } else { ctx.Flash.Info(ctx.Tr("admin.config.test_mail_sent", email)) diff --git a/routers/admin/users.go b/routers/admin/users.go index 76fbcd1683..2eca243b6c 100644 --- a/routers/admin/users.go +++ b/routers/admin/users.go @@ -14,7 +14,6 @@ import ( "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/context" "github.com/gogits/gogs/modules/log" - "github.com/gogits/gogs/modules/mailer" "github.com/gogits/gogs/modules/setting" "github.com/gogits/gogs/routers" ) @@ -115,9 +114,9 @@ func NewUserPost(ctx *context.Context, form auth.AdminCrateUserForm) { } log.Trace("Account created by admin (%s): %s", ctx.User.Name, u.Name) - // Send e-mail notification. + // Send email notification. if form.SendNotify && setting.MailService != nil { - mailer.SendRegisterNotifyMail(ctx.Context, u) + models.SendRegisterNotifyMail(ctx.Context, u) } ctx.Flash.Success(ctx.Tr("admin.users.new_success", u.Name)) diff --git a/routers/api/v1/admin/user.go b/routers/api/v1/admin/user.go index ce13804ffb..4bb24998bb 100644 --- a/routers/api/v1/admin/user.go +++ b/routers/api/v1/admin/user.go @@ -10,7 +10,6 @@ import ( "github.com/gogits/gogs/models" "github.com/gogits/gogs/modules/context" "github.com/gogits/gogs/modules/log" - "github.com/gogits/gogs/modules/mailer" "github.com/gogits/gogs/modules/setting" "github.com/gogits/gogs/routers/api/v1/convert" "github.com/gogits/gogs/routers/api/v1/user" @@ -64,9 +63,9 @@ func CreateUser(ctx *context.APIContext, form api.CreateUserOption) { } log.Trace("Account created by admin (%s): %s", ctx.User.Name, u.Name) - // Send e-mail notification. + // Send email notification. if form.SendNotify && setting.MailService != nil { - mailer.SendRegisterNotifyMail(ctx.Context.Context, u) + models.SendRegisterNotifyMail(ctx.Context.Context, u) } ctx.JSON(201, convert.ToUser(u)) diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go index a80adbc356..bf2c8e9ddf 100644 --- a/routers/api/v1/repo/issue.go +++ b/routers/api/v1/repo/issue.go @@ -14,7 +14,6 @@ import ( "github.com/gogits/gogs/modules/context" "github.com/gogits/gogs/modules/setting" "github.com/gogits/gogs/routers/api/v1/convert" - "github.com/gogits/gogs/routers/repo" ) func ListIssues(ctx *context.APIContext) { @@ -80,9 +79,6 @@ func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) { if err := models.NewIssue(ctx.Repo.Repository, issue, form.Labels, nil); err != nil { ctx.Error(500, "NewIssue", err) return - } else if err := repo.MailWatchersAndMentions(ctx.Context, issue); err != nil { - ctx.Error(500, "MailWatchersAndMentions", err) - return } if form.Closed { diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 4f75532b3d..accf51d1ec 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -22,7 +22,6 @@ import ( "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/context" "github.com/gogits/gogs/modules/log" - "github.com/gogits/gogs/modules/mailer" "github.com/gogits/gogs/modules/markdown" "github.com/gogits/gogs/modules/setting" ) @@ -395,46 +394,6 @@ func ValidateRepoMetas(ctx *context.Context, form auth.CreateIssueForm) ([]int64 return labelIDs, milestoneID, assigneeID } -func MailWatchersAndMentions(ctx *context.Context, issue *models.Issue) error { - // Update mentions - mentions := markdown.MentionPattern.FindAllString(issue.Content, -1) - if len(mentions) > 0 { - for i := range mentions { - mentions[i] = strings.TrimSpace(mentions[i])[1:] - } - - if err := models.UpdateMentions(mentions, issue.ID); err != nil { - return fmt.Errorf("UpdateMentions: %v", err) - } - } - - repo := ctx.Repo.Repository - - // Mail watchers and mentions. - if setting.Service.EnableNotifyMail { - tos, err := mailer.SendIssueNotifyMail(ctx.User, ctx.Repo.Owner, repo, issue) - if err != nil { - return fmt.Errorf("SendIssueNotifyMail: %v", err) - } - - tos = append(tos, ctx.User.LowerName) - newTos := make([]string, 0, len(mentions)) - for _, m := range mentions { - if com.IsSliceContainsStr(tos, m) { - continue - } - - newTos = append(newTos, m) - } - if err = mailer.SendIssueMentionMail(ctx.Render, ctx.User, ctx.Repo.Owner, - repo, issue, models.GetUserEmailsByNames(newTos)); err != nil { - return fmt.Errorf("SendIssueMentionMail: %v", err) - } - } - - return nil -} - func NewIssuePost(ctx *context.Context, form auth.CreateIssueForm) { ctx.Data["Title"] = ctx.Tr("repo.issues.new") ctx.Data["PageIsIssueList"] = true @@ -471,9 +430,6 @@ func NewIssuePost(ctx *context.Context, form auth.CreateIssueForm) { if err := models.NewIssue(repo, issue, labelIDs, attachments); err != nil { ctx.Handle(500, "NewIssue", err) return - } else if err := MailWatchersAndMentions(ctx, issue); err != nil { - ctx.Handle(500, "MailWatchersAndMentions", err) - return } log.Trace("Issue created: %d/%d", repo.ID, issue.ID) @@ -933,16 +889,6 @@ func NewComment(ctx *context.Context, form auth.CreateCommentForm) { return } - MailWatchersAndMentions(ctx, &models.Issue{ - ID: issue.ID, - Index: issue.Index, - Name: issue.Name, - Content: form.Content, - }) - if ctx.Written() { - return - } - log.Trace("Comment created: %d/%d/%d", ctx.Repo.Repository.ID, issue.ID, comment.ID) } @@ -1024,7 +970,6 @@ func UpdateLabel(ctx *context.Context, form auth.CreateLabelForm) { return } - fmt.Println(form.Title, form.Color) l.Name = form.Title l.Color = form.Color if err := models.UpdateLabel(l); err != nil { diff --git a/routers/repo/pull.go b/routers/repo/pull.go index da1ee14996..56245a8766 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -681,9 +681,6 @@ func CompareAndPullRequestPost(ctx *context.Context, form auth.CreateIssueForm) } else if err := pullRequest.PushToBaseRepo(); err != nil { ctx.Handle(500, "PushToBaseRepo", err) return - } else if err := MailWatchersAndMentions(ctx, pullIssue); err != nil { - ctx.Handle(500, "MailWatchersAndMentions", err) - return } log.Trace("Pull request created: %d/%d", repo.ID, pullIssue.ID) diff --git a/routers/repo/setting.go b/routers/repo/setting.go index 6fd195aa10..c9236a5331 100644 --- a/routers/repo/setting.go +++ b/routers/repo/setting.go @@ -15,7 +15,6 @@ import ( "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/context" "github.com/gogits/gogs/modules/log" - "github.com/gogits/gogs/modules/mailer" "github.com/gogits/gogs/modules/setting" ) @@ -325,10 +324,7 @@ func CollaborationPost(ctx *context.Context) { } if setting.Service.EnableNotifyMail { - if err = mailer.SendCollaboratorMail(ctx.Render, u, ctx.User, ctx.Repo.Repository); err != nil { - ctx.Handle(500, "SendCollaboratorMail", err) - return - } + models.SendCollaboratorMail(u, ctx.User, ctx.Repo.Repository) } ctx.Flash.Success(ctx.Tr("repo.settings.add_collaborator_success")) diff --git a/routers/user/auth.go b/routers/user/auth.go index 9b48357aaa..df79ecbe4c 100644 --- a/routers/user/auth.go +++ b/routers/user/auth.go @@ -15,7 +15,6 @@ import ( "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/context" "github.com/gogits/gogs/modules/log" - "github.com/gogits/gogs/modules/mailer" "github.com/gogits/gogs/modules/setting" ) @@ -220,9 +219,9 @@ func SignUpPost(ctx *context.Context, cpt *captcha.Captcha, form auth.RegisterFo } } - // Send confirmation e-mail, no need for social account. + // Send confirmation email, no need for social account. if setting.Service.RegisterEmailConfirm && u.Id > 1 { - mailer.SendActivateAccountMail(ctx.Context, u) + models.SendActivateAccountMail(ctx.Context, u) ctx.Data["IsSendRegisterMail"] = true ctx.Data["Email"] = u.Email ctx.Data["Hours"] = setting.Service.ActiveCodeLives / 60 @@ -245,13 +244,13 @@ func Activate(ctx *context.Context) { ctx.Error(404) return } - // Resend confirmation e-mail. + // Resend confirmation email. if setting.Service.RegisterEmailConfirm { if ctx.Cache.IsExist("MailResendLimit_" + ctx.User.LowerName) { ctx.Data["ResendLimited"] = true } else { ctx.Data["Hours"] = setting.Service.ActiveCodeLives / 60 - mailer.SendActivateAccountMail(ctx.Context, ctx.User) + models.SendActivateAccountMail(ctx.Context, ctx.User) if err := ctx.Cache.Put("MailResendLimit_"+ctx.User.LowerName, ctx.User.LowerName, 180); err != nil { log.Error(4, "Set cache(MailResendLimit) fail: %v", err) @@ -355,7 +354,7 @@ func ForgotPasswdPost(ctx *context.Context) { return } - mailer.SendResetPasswordMail(ctx.Context, u) + models.SendResetPasswordMail(ctx.Context, u) if err = ctx.Cache.Put("MailResendLimit_"+u.LowerName, u.LowerName, 180); err != nil { log.Error(4, "Set cache(MailResendLimit) fail: %v", err) } diff --git a/routers/user/setting.go b/routers/user/setting.go index 4b62bb11cc..c910cd4e14 100644 --- a/routers/user/setting.go +++ b/routers/user/setting.go @@ -17,7 +17,6 @@ import ( "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/context" "github.com/gogits/gogs/modules/log" - "github.com/gogits/gogs/modules/mailer" "github.com/gogits/gogs/modules/setting" ) @@ -239,12 +238,12 @@ func SettingsEmailPost(ctx *context.Context, form auth.AddEmailForm) { return } - e := &models.EmailAddress{ + email := &models.EmailAddress{ UID: ctx.User.Id, Email: form.Email, IsActivated: !setting.Service.RegisterEmailConfirm, } - if err := models.AddEmailAddress(e); err != nil { + if err := models.AddEmailAddress(email); err != nil { if models.IsErrEmailAlreadyUsed(err) { ctx.RenderWithErr(ctx.Tr("form.email_been_used"), SETTINGS_EMAILS, &form) return @@ -253,19 +252,19 @@ func SettingsEmailPost(ctx *context.Context, form auth.AddEmailForm) { return } - // Send confirmation e-mail + // Send confirmation email if setting.Service.RegisterEmailConfirm { - mailer.SendActivateEmailMail(ctx.Context, ctx.User, e) + models.SendActivateEmailMail(ctx.Context, ctx.User, email) if err := ctx.Cache.Put("MailResendLimit_"+ctx.User.LowerName, ctx.User.LowerName, 180); err != nil { log.Error(4, "Set cache(MailResendLimit) fail: %v", err) } - ctx.Flash.Info(ctx.Tr("settings.add_email_confirmation_sent", e.Email, setting.Service.ActiveCodeLives/60)) + ctx.Flash.Info(ctx.Tr("settings.add_email_confirmation_sent", email.Email, setting.Service.ActiveCodeLives/60)) } else { ctx.Flash.Success(ctx.Tr("settings.add_email_success")) } - log.Trace("Email address added: %s", e.Email) + log.Trace("Email address added: %s", email.Email) ctx.Redirect(setting.AppSubUrl + "/user/settings/email") } |