summaryrefslogtreecommitdiffstats
path: root/services/mailer/mail_comment.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-08-12 08:26:33 +0100
committerGitHub <noreply@github.com>2021-08-12 10:26:33 +0300
commit162c32af7ec9cc434895079cfc7bfc683feb4d4c (patch)
tree5110a77931917910e4a92b92705a185891a0ff83 /services/mailer/mail_comment.go
parente29e1637370ad95e4ca9f861c25d366b74829dcc (diff)
downloadgitea-162c32af7ec9cc434895079cfc7bfc683feb4d4c.tar.gz
gitea-162c32af7ec9cc434895079cfc7bfc683feb4d4c.zip
Send registration email on user autoregistration (#16523)
When users login and are autoregistered send email notification. Fix #16178 * Protect public functions within the mailer by testing if the mailer is configured Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'services/mailer/mail_comment.go')
-rw-r--r--services/mailer/mail_comment.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/services/mailer/mail_comment.go b/services/mailer/mail_comment.go
index eca05cef29..eef71557e7 100644
--- a/services/mailer/mail_comment.go
+++ b/services/mailer/mail_comment.go
@@ -7,10 +7,16 @@ package mailer
import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/log"
+ "code.gitea.io/gitea/modules/setting"
)
// MailParticipantsComment sends new comment emails to repository watchers and mentioned people.
func MailParticipantsComment(c *models.Comment, opType models.ActionType, issue *models.Issue, mentions []*models.User) error {
+ if setting.MailService == nil {
+ // No mail service configured
+ return nil
+ }
+
content := c.Content
if c.Type == models.CommentTypePullPush {
content = ""
@@ -30,6 +36,11 @@ func MailParticipantsComment(c *models.Comment, opType models.ActionType, issue
// MailMentionsComment sends email to users mentioned in a code comment
func MailMentionsComment(pr *models.PullRequest, c *models.Comment, mentions []*models.User) (err error) {
+ if setting.MailService == nil {
+ // No mail service configured
+ return nil
+ }
+
visited := make(map[int64]bool, len(mentions)+1)
visited[c.Poster.ID] = true
if err = mailIssueCommentBatch(