Add mail notify for new collaborator
This commit is contained in:
parent
07c3d497a7
commit
02687cbdf3
7 changed files with 93 additions and 18 deletions
|
@ -132,8 +132,8 @@ func CreateIssuePost(ctx *middleware.Context, params martini.Params, form auth.C
|
|||
|
||||
newTos = append(newTos, m[1:])
|
||||
}
|
||||
if err = mailer.SendIssueMentionMail(ctx.User, ctx.Repo.Owner, ctx.Repo.Repository,
|
||||
issue, models.GetUserEmailsByNames(newTos)); err != nil {
|
||||
if err = mailer.SendIssueMentionMail(ctx.Render, ctx.User, ctx.Repo.Owner,
|
||||
ctx.Repo.Repository, issue, models.GetUserEmailsByNames(newTos)); err != nil {
|
||||
ctx.Handle(500, "issue.CreateIssue(SendIssueMentionMail)", err)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
"github.com/gogits/gogs/modules/mailer"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
)
|
||||
|
||||
|
@ -185,22 +186,30 @@ func CollaborationPost(ctx *middleware.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
isExist, err := models.IsUserExist(name)
|
||||
u, err := models.GetUserByName(name)
|
||||
if err != nil {
|
||||
ctx.Handle(500, "repo.CollaborationPost(IsUserExist)", err)
|
||||
return
|
||||
} else if !isExist {
|
||||
ctx.Flash.Error("Given user does not exist.")
|
||||
ctx.Redirect(ctx.Req.RequestURI)
|
||||
if err == models.ErrUserNotExist {
|
||||
ctx.Flash.Error("Given user does not exist.")
|
||||
ctx.Redirect(ctx.Req.RequestURI)
|
||||
} else {
|
||||
ctx.Handle(500, "repo.CollaborationPost(GetUserByName)", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if err := models.AddAccess(&models.Access{UserName: name, RepoName: repoLink,
|
||||
if err = models.AddAccess(&models.Access{UserName: name, RepoName: repoLink,
|
||||
Mode: models.AU_WRITABLE}); err != nil {
|
||||
ctx.Handle(500, "repo.CollaborationPost(AddAccess)", err)
|
||||
return
|
||||
}
|
||||
|
||||
if base.Service.NotifyMail {
|
||||
if err = mailer.SendCollaboratorMail(ctx.Render, u, ctx.User, ctx.Repo.Repository); err != nil {
|
||||
ctx.Handle(500, "repo.CollaborationPost(SendCollaboratorMail)", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
ctx.Flash.Success("New collaborator has been added.")
|
||||
ctx.Redirect(ctx.Req.RequestURI)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue