diff options
author | zeripath <art27@cantab.net> | 2021-08-12 08:26:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-12 10:26:33 +0300 |
commit | 162c32af7ec9cc434895079cfc7bfc683feb4d4c (patch) | |
tree | 5110a77931917910e4a92b92705a185891a0ff83 /services/mailer/mail_repo.go | |
parent | e29e1637370ad95e4ca9f861c25d366b74829dcc (diff) | |
download | gitea-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_repo.go')
-rw-r--r-- | services/mailer/mail_repo.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/services/mailer/mail_repo.go b/services/mailer/mail_repo.go index 4e629ee5c7..ef85f4aa54 100644 --- a/services/mailer/mail_repo.go +++ b/services/mailer/mail_repo.go @@ -9,12 +9,18 @@ import ( "fmt" "code.gitea.io/gitea/models" + "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/templates" "code.gitea.io/gitea/modules/translation" ) // SendRepoTransferNotifyMail triggers a notification e-mail when a pending repository transfer was created func SendRepoTransferNotifyMail(doer, newOwner *models.User, repo *models.Repository) error { + if setting.MailService == nil { + // No mail service configured + return nil + } + if newOwner.IsOrganization() { users, err := models.GetUsersWhoCanCreateOrgRepo(newOwner.ID) if err != nil { |