diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini
index 5f573723b6..d912950bf9 100644
--- a/custom/conf/app.example.ini
+++ b/custom/conf/app.example.ini
@@ -1455,8 +1455,8 @@ LEVEL = Info
;;
;; Default configuration for email notifications for users (user configurable). Options: enabled, onmention, disabled
;DEFAULT_EMAIL_NOTIFICATIONS = enabled
-;; Send email notifications to all instance admins on new user sign-ups. Options: enabled, true, false
-;NOTIFY_NEW_SIGN_UPS = false
+;; Send an email to all admins when a new user signs up to inform the admins about this act. Options: true, false
+;SEND_NOTIFICATION_EMAIL_ON_NEW_USER = false
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
diff --git a/docs/content/administration/config-cheat-sheet.en-us.md b/docs/content/administration/config-cheat-sheet.en-us.md
index aa29f8be4b..120c918ddc 100644
--- a/docs/content/administration/config-cheat-sheet.en-us.md
+++ b/docs/content/administration/config-cheat-sheet.en-us.md
@@ -510,6 +510,7 @@ And the following unique queues:
- `DEFAULT_EMAIL_NOTIFICATIONS`: **enabled**: Default configuration for email notifications for users (user configurable). Options: enabled, onmention, disabled
- `DISABLE_REGULAR_ORG_CREATION`: **false**: Disallow regular (non-admin) users from creating organizations.
+- `SEND_NOTIFICATION_EMAIL_ON_NEW_USER`: **false**: Send an email to all admins when a new user signs up to inform the admins about this act.
## Security (`security`)
diff --git a/modules/setting/admin.go b/modules/setting/admin.go
index 4e2f343715..d7f0ee827d 100644
--- a/modules/setting/admin.go
+++ b/modules/setting/admin.go
@@ -5,9 +5,9 @@ package setting
// Admin settings
var Admin struct {
- DisableRegularOrgCreation bool
- DefaultEmailNotification string
- NotifyNewSignUps bool
+ DisableRegularOrgCreation bool
+ DefaultEmailNotification string
+ SendNotificationEmailOnNewUser bool
}
func loadAdminFrom(rootCfg ConfigProvider) {
diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini
index e49eb31bea..243b5dcfa6 100644
--- a/options/locale/locale_en-US.ini
+++ b/options/locale/locale_en-US.ini
@@ -439,7 +439,7 @@ activate_email = Verify your email address
activate_email.title = %s, please verify your email address
activate_email.text = Please click the following link to verify your email address within %s:
-admin.new_user.subject = New user %s
+admin.new_user.subject = New user %s just signed up
admin.new_user.user_info = User Information
admin.new_user.text = Please click here to manage the user from the admin panel.
diff --git a/services/mailer/mail_admin_new_user.go b/services/mailer/mail_admin_new_user.go
index fbed615b67..47b110412c 100644
--- a/services/mailer/mail_admin_new_user.go
+++ b/services/mailer/mail_admin_new_user.go
@@ -16,14 +16,14 @@ import (
)
const (
- tplNewUserMail base.TplName = "admin_new_user"
+ tplNewUserMail base.TplName = "notify/admin_new_user"
)
var sa = SendAsyncs
// MailNewUser sends notification emails on new user registrations to all admins
func MailNewUser(ctx context.Context, u *user_model.User) {
- if !setting.Admin.NotifyNewSignUps {
+ if !setting.Admin.SendNotificationEmailOnNewUser {
return
}
diff --git a/services/mailer/mail_admin_new_user_test.go b/services/mailer/mail_admin_new_user_test.go
index d79566c648..4bb8d6a7a0 100644
--- a/services/mailer/mail_admin_new_user_test.go
+++ b/services/mailer/mail_admin_new_user_test.go
@@ -21,13 +21,13 @@ func getTestUsers() []*user_model.User {
admin.Name = "admin"
admin.IsAdmin = true
admin.Language = "en_US"
- admin.Email = "admin@forgejo.org"
+ admin.Email = "admin@example.com"
newUser := new(user_model.User)
newUser.Name = "new_user"
newUser.Language = "en_US"
newUser.IsAdmin = false
- newUser.Email = "new_user@forgejo.org"
+ newUser.Email = "new_user@example.com"
newUser.LastLoginUnix = 1693648327
newUser.CreatedUnix = 1693648027
@@ -49,7 +49,7 @@ func cleanUpUsers(ctx context.Context, users []*user_model.User) {
func TestAdminNotificationMail_test(t *testing.T) {
mailService := setting.Mailer{
- From: "test@forgejo.org",
+ From: "test@example.com",
Protocol: "dummy",
}
@@ -57,8 +57,8 @@ func TestAdminNotificationMail_test(t *testing.T) {
setting.Domain = "localhost"
setting.AppSubURL = "http://localhost"
- // test with NOTIFY_NEW_SIGNUPS enabled
- setting.Admin.NotifyNewSignUps = true
+ // test with SEND_NOTIFICATION_EMAIL_ON_NEW_USER enabled
+ setting.Admin.SendNotificationEmailOnNewUser = true
ctx := context.Background()
NewContext(ctx)
@@ -78,10 +78,10 @@ func TestAdminNotificationMail_test(t *testing.T) {
}
MailNewUser(ctx, users[1])
- // test with NOTIFY_NEW_SIGNUPS disabled; emails shouldn't be sent
- setting.Admin.NotifyNewSignUps = false
+ // test with SEND_NOTIFICATION_EMAIL_ON_NEW_USER disabled; emails shouldn't be sent
+ setting.Admin.SendNotificationEmailOnNewUser = false
sa = func(msgs []*Message) {
- assert.Equal(t, 1, 0, "this shouldn't execute. MailNewUser must exit early since NOTIFY_NEW_SIGNUPS is disabled")
+ assert.Equal(t, 1, 0, "this shouldn't execute. MailNewUser must exit early since SEND_NOTIFICATION_EMAIL_ON_NEW_USER is disabled")
}
MailNewUser(ctx, users[1])
diff --git a/services/notify/notify.go b/services/notify/notify.go
index 1f7722f703..9cb329d302 100644
--- a/services/notify/notify.go
+++ b/services/notify/notify.go
@@ -347,7 +347,7 @@ func RepoPendingTransfer(ctx context.Context, doer, newOwner *user_model.User, r
}
}
-// NewUserSignUp notifies deletion of a package to notifiers
+// NewUserSignUp notifies about a newly signed up user to notifiers
func NewUserSignUp(ctx context.Context, newUser *user_model.User) {
for _, notifier := range notifiers {
notifier.NewUserSignUp(ctx, newUser)
diff --git a/services/notify/null.go b/services/notify/null.go
index 847a18d1af..894d118eac 100644
--- a/services/notify/null.go
+++ b/services/notify/null.go
@@ -197,7 +197,6 @@ func (*NullNotifier) SyncDeleteRef(ctx context.Context, doer *user_model.User, r
func (*NullNotifier) RepoPendingTransfer(ctx context.Context, doer, newOwner *user_model.User, repo *repo_model.Repository) {
}
-// NotifyNewUserSignUp notifies deletion of a package to notifiers
func (*NullNotifier) NewUserSignUp(ctx context.Context, newUser *user_model.User) {
}
diff --git a/templates/mail/admin_new_user.tmpl b/templates/mail/notify/admin_new_user.tmpl
similarity index 100%
rename from templates/mail/admin_new_user.tmpl
rename to templates/mail/notify/admin_new_user.tmpl