aboutsummaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2022-03-19 12:45:44 +0000
committerGitHub <noreply@github.com>2022-03-19 20:45:44 +0800
commitfb08d2b3fd04dc8fc6cbd45fd341773b817c0857 (patch)
tree5f8c5da22ab64e5421fe5ca5075ab8fe8eca9355 /services
parent60fbaa90683add2a8af891fc2ca8448b9b75c92e (diff)
downloadgitea-fb08d2b3fd04dc8fc6cbd45fd341773b817c0857.tar.gz
gitea-fb08d2b3fd04dc8fc6cbd45fd341773b817c0857.zip
Do not send notification emails to inactive users (#19131)
Emails should not be sent to inactive users except for Activate and ResetPassword messages. Fix #18950 Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'services')
-rw-r--r--services/mailer/mail.go12
-rw-r--r--services/mailer/mail_repo.go4
2 files changed, 12 insertions, 4 deletions
diff --git a/services/mailer/mail.go b/services/mailer/mail.go
index 3983237fc5..8c99b05620 100644
--- a/services/mailer/mail.go
+++ b/services/mailer/mail.go
@@ -146,8 +146,8 @@ func SendActivateEmailMail(u *user_model.User, email *user_model.EmailAddress) {
// SendRegisterNotifyMail triggers a notify e-mail by admin created a account.
func SendRegisterNotifyMail(u *user_model.User) {
- if setting.MailService == nil {
- // No mail service configured
+ if setting.MailService == nil || !u.IsActive {
+ // No mail service configured OR user is inactive
return
}
locale := translation.NewLocale(u.Language)
@@ -176,8 +176,8 @@ func SendRegisterNotifyMail(u *user_model.User) {
// SendCollaboratorMail sends mail notification to new collaborator.
func SendCollaboratorMail(u, doer *user_model.User, repo *repo_model.Repository) {
- if setting.MailService == nil {
- // No mail service configured
+ if setting.MailService == nil || !u.IsActive {
+ // No mail service configured OR the user is inactive
return
}
locale := translation.NewLocale(u.Language)
@@ -405,6 +405,10 @@ func SendIssueAssignedMail(issue *models.Issue, doer *user_model.User, content s
langMap := make(map[string][]*user_model.User)
for _, user := range recipients {
+ if !user.IsActive {
+ // don't send emails to inactive users
+ continue
+ }
langMap[user.Language] = append(langMap[user.Language], user)
}
diff --git a/services/mailer/mail_repo.go b/services/mailer/mail_repo.go
index a5343f8128..24e6d671f4 100644
--- a/services/mailer/mail_repo.go
+++ b/services/mailer/mail_repo.go
@@ -31,6 +31,10 @@ func SendRepoTransferNotifyMail(doer, newOwner *user_model.User, repo *repo_mode
langMap := make(map[string][]string)
for _, user := range users {
+ if !user.IsActive {
+ // don't send emails to inactive users
+ continue
+ }
langMap[user.Language] = append(langMap[user.Language], user.Email)
}