mirror of
https://github.com/mjl-/mox.git
synced 2025-07-19 03:26:37 +03:00
Allow multiple localpart catch all separators, e.g. both "+" and "-", for addresses you+anything@example.com and you-anything@example.com
The original config option stays, and we still use it for the common case where we have a single separator. The "+" is configured by default. It is optional, just like the new option "LocalpartCatchallSeparators" (plural). When parsing the config file, we combine LocalpartCatchallSeparator and LocalpartCatchallSeparators into a single list LocalpartCatchallSeparatorsEffective, which we use throughout the code. For issue #301 by janc13
This commit is contained in:
@ -2527,9 +2527,19 @@ func (Admin) DomainClientSettingsDomainSave(ctx context.Context, domainName, cli
|
||||
|
||||
// DomainLocalpartConfigSave saves the localpart catchall and case-sensitive
|
||||
// settings for a domain.
|
||||
func (Admin) DomainLocalpartConfigSave(ctx context.Context, domainName, localpartCatchallSeparator string, localpartCaseSensitive bool) {
|
||||
func (Admin) DomainLocalpartConfigSave(ctx context.Context, domainName string, localpartCatchallSeparators []string, localpartCaseSensitive bool) {
|
||||
err := admin.DomainSave(ctx, domainName, func(domain *config.Domain) error {
|
||||
domain.LocalpartCatchallSeparator = localpartCatchallSeparator
|
||||
domain.LocalpartCatchallSeparatorsEffective = localpartCatchallSeparators
|
||||
// If there is a single separator, we prefer the non-list form, it's easier to
|
||||
// read/edit and should suffice for most setups.
|
||||
domain.LocalpartCatchallSeparator = ""
|
||||
domain.LocalpartCatchallSeparators = nil
|
||||
if len(localpartCatchallSeparators) == 1 {
|
||||
domain.LocalpartCatchallSeparator = localpartCatchallSeparators[0]
|
||||
} else {
|
||||
domain.LocalpartCatchallSeparators = localpartCatchallSeparators
|
||||
}
|
||||
|
||||
domain.LocalpartCaseSensitive = localpartCaseSensitive
|
||||
return nil
|
||||
})
|
||||
|
Reference in New Issue
Block a user