deprecate having only localparts in an Account's Destinations, it should always be a full email address

current behaviour isn't intuitive. it's not great to have to attempt parsing
the strings as both localpart and email address. so we deprecate the
localpart-only behaviour. when we load the config file, and it has
localpart-only Destinations keys, we'll change them to full addresses in
memory. when an admin causes a write of domains.conf, it'll automatically be
fixed. we log an error with a deprecated notice for each localpart-only
destinations key.

sometime in the future, we can remove the old localpart-only destination
support. will be in the release notes then.

also start keeping track of update notes that need to make it in the release
notes of the next release.

for issue #18
This commit is contained in:
Mechiel Lukkien
2023-03-09 22:07:37 +01:00
parent 5742ed1537
commit 2c07645ab4
20 changed files with 57 additions and 41 deletions

View File

@ -115,7 +115,7 @@ func MakeAccountConfig(addr smtp.Address) config.Account {
account := config.Account{
Domain: addr.Domain.Name(),
Destinations: map[string]config.Destination{
addr.Localpart.String(): {},
addr.String(): {},
},
RejectsMailbox: "Rejects",
JunkFilter: &config.JunkFilter{
@ -676,13 +676,7 @@ func AddressAdd(ctx context.Context, address, account string) (rerr error) {
for name, d := range a.Destinations {
nd[name] = d
}
var k string
if addr.Domain == a.DNSDomain {
k = addr.Localpart.String()
} else {
k = addr.String()
}
nd[k] = config.Destination{}
nd[addr.String()] = config.Destination{}
a.Destinations = nd
nc.Accounts[account] = a
@ -727,6 +721,7 @@ func AddressRemove(ctx context.Context, address string) (rerr error) {
na.Destinations = map[string]config.Destination{}
var dropped bool
for name, d := range a.Destinations {
// todo deprecated: remove support for localpart-only with default domain as destination address.
if !(name == addr.Localpart.String() && a.DNSDomain == addr.Domain || name == addrStr) {
na.Destinations[name] = d
} else {