Merge pull request '[v7.0/forgejo] fix(services): set SendNotificationEmailOnNewUser' (#3906) from bp-v7.0/forgejo-ff2a3f4 into v7.0/forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/3906
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
This commit is contained in:
Earl Warren 2024-05-25 15:58:01 +00:00
commit 16debbc792
3 changed files with 32 additions and 0 deletions

View file

@ -17,6 +17,7 @@ func loadAdminFrom(rootCfg ConfigProvider) {
sec := rootCfg.Section("admin")
Admin.DisableRegularOrgCreation = sec.Key("DISABLE_REGULAR_ORG_CREATION").MustBool(false)
Admin.DefaultEmailNotification = sec.Key("DEFAULT_EMAIL_NOTIFICATIONS").MustString("enabled")
Admin.SendNotificationEmailOnNewUser = sec.Key("SEND_NOTIFICATION_EMAIL_ON_NEW_USER").MustBool(false)
Admin.UserDisabledFeatures = container.SetOf(sec.Key("USER_DISABLED_FEATURES").Strings(",")...)
}

View file

@ -0,0 +1,30 @@
// Copyright The Forgejo Authors.
// SPDX-License-Identifier: MIT
package setting
import (
"testing"
"code.gitea.io/gitea/modules/container"
"github.com/stretchr/testify/assert"
)
func Test_loadAdminFrom(t *testing.T) {
iniStr := `
[admin]
DISABLE_REGULAR_ORG_CREATION = true
DEFAULT_EMAIL_NOTIFICATIONS = z
SEND_NOTIFICATION_EMAIL_ON_NEW_USER = true
USER_DISABLED_FEATURES = a,b
`
cfg, err := NewConfigProviderFromData(iniStr)
assert.NoError(t, err)
loadAdminFrom(cfg)
assert.EqualValues(t, true, Admin.DisableRegularOrgCreation)
assert.EqualValues(t, "z", Admin.DefaultEmailNotification)
assert.EqualValues(t, true, Admin.SendNotificationEmailOnNewUser)
assert.EqualValues(t, container.SetOf("a", "b"), Admin.UserDisabledFeatures)
}

View file

@ -0,0 +1 @@
- a v7.0.0 regression causing `[admin].SEND_NOTIFICATION_EMAIL_ON_NEW_USER=true` to always be ignored.