allways set a message-id on mails (#17900)

* allways set a message-id on mails
* Add unit tests for mailer & Message-ID

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
Garionion 2021-12-08 08:34:23 +01:00 committed by GitHub
parent 0ff18a808c
commit b59875aa12
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 66 additions and 5 deletions

View file

@ -548,17 +548,17 @@ func SetCustomPathAndConf(providedCustom, providedConf, providedWorkPath string)
// LoadFromExisting initializes setting options from an existing config file (app.ini)
func LoadFromExisting() {
loadFromConf(false)
loadFromConf(false, "")
}
// LoadAllowEmpty initializes setting options, it's also fine that if the config file (app.ini) doesn't exist
func LoadAllowEmpty() {
loadFromConf(true)
loadFromConf(true, "")
}
// LoadForTest initializes setting options for tests
func LoadForTest() {
loadFromConf(true)
func LoadForTest(extraConfigs ...string) {
loadFromConf(true, strings.Join(extraConfigs, "\n"))
if err := PrepareAppDataPath(); err != nil {
log.Fatal("Can not prepare APP_DATA_PATH: %v", err)
}
@ -566,7 +566,7 @@ func LoadForTest() {
// loadFromConf initializes configuration context.
// NOTE: do not print any log except error.
func loadFromConf(allowEmpty bool) {
func loadFromConf(allowEmpty bool, extraConfig string) {
Cfg = ini.Empty()
if WritePIDFile && len(PIDFile) > 0 {
@ -585,6 +585,12 @@ func loadFromConf(allowEmpty bool) {
log.Fatal("Unable to find configuration file: %q.\nEnsure you are running in the correct environment or set the correct configuration file with -c.", CustomConf)
} // else: no config file, a config file might be created at CustomConf later (might not)
if extraConfig != "" {
if err = Cfg.Append([]byte(extraConfig)); err != nil {
log.Fatal("Unable to append more config: %v", err)
}
}
Cfg.NameMapper = ini.SnackCase
homeDir, err := com.HomeDir()