|
|
|
@ -111,11 +111,11 @@ func SendResetPasswdMail(r *middleware.Render, user *models.User) {
|
|
|
|
|
SendAsync(&msg) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// SendNotifyMail sends mail notification of all watchers.
|
|
|
|
|
func SendNotifyMail(user, owner *models.User, repo *models.Repository, issue *models.Issue) error { |
|
|
|
|
// SendIssueNotifyMail sends mail notification of all watchers of repository.
|
|
|
|
|
func SendIssueNotifyMail(user, owner *models.User, repo *models.Repository, issue *models.Issue) ([]string, error) { |
|
|
|
|
watches, err := models.GetWatches(repo.Id) |
|
|
|
|
if err != nil { |
|
|
|
|
return errors.New("mail.NotifyWatchers(get watches): " + err.Error()) |
|
|
|
|
return nil, errors.New("mail.NotifyWatchers(get watches): " + err.Error()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
tos := make([]string, 0, len(watches)) |
|
|
|
@ -126,20 +126,37 @@ func SendNotifyMail(user, owner *models.User, repo *models.Repository, issue *mo
|
|
|
|
|
} |
|
|
|
|
u, err := models.GetUserById(uid) |
|
|
|
|
if err != nil { |
|
|
|
|
return errors.New("mail.NotifyWatchers(get user): " + err.Error()) |
|
|
|
|
return nil, errors.New("mail.NotifyWatchers(get user): " + err.Error()) |
|
|
|
|
} |
|
|
|
|
tos = append(tos, u.Email) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if len(tos) == 0 { |
|
|
|
|
return nil |
|
|
|
|
return tos, nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
subject := fmt.Sprintf("[%s] %s", repo.Name, issue.Name) |
|
|
|
|
content := fmt.Sprintf("%s<br>-<br> <a href=\"%s%s/%s/issues/%d\">View it on Gogs</a>.", |
|
|
|
|
issue.Content, base.AppUrl, owner.Name, repo.Name, issue.Index) |
|
|
|
|
base.RenderSpecialLink([]byte(issue.Content), owner.Name+"/"+repo.Name), |
|
|
|
|
base.AppUrl, owner.Name, repo.Name, issue.Index) |
|
|
|
|
msg := NewMailMessageFrom(tos, user.Name, subject, content) |
|
|
|
|
msg.Info = fmt.Sprintf("Subject: %s, send issue notify emails", subject) |
|
|
|
|
SendAsync(&msg) |
|
|
|
|
return tos, nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// SendIssueMentionMail sends mail notification for who are mentioned in issue.
|
|
|
|
|
func SendIssueMentionMail(user, owner *models.User, repo *models.Repository, issue *models.Issue, tos []string) error { |
|
|
|
|
if len(tos) == 0 { |
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
issueLink := fmt.Sprintf("%s%s/%s/issues/%d", base.AppUrl, owner.Name, repo.Name, issue.Index) |
|
|
|
|
body := fmt.Sprintf(`%s mentioned you.`) |
|
|
|
|
subject := fmt.Sprintf("[%s] %s", repo.Name, issue.Name) |
|
|
|
|
content := fmt.Sprintf("%s<br>-<br> <a href=\"%s\">View it on Gogs</a>.", body, issueLink) |
|
|
|
|
msg := NewMailMessageFrom(tos, user.Name, subject, content) |
|
|
|
|
msg.Info = fmt.Sprintf("Subject: %s, send notify emails", subject) |
|
|
|
|
msg.Info = fmt.Sprintf("Subject: %s, send issue mention emails", subject) |
|
|
|
|
SendAsync(&msg) |
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|