diff options
author | Reto Brunner <reto@labrat.space> | 2020-08-19 12:01:45 +0200 |
---|---|---|
committer | Reto Brunner <reto@labrat.space> | 2020-08-20 19:18:57 +0200 |
commit | c84630714405a1e93766a6a6c023801302a3ea66 (patch) | |
tree | 156e9f45c6847a123f677594c8aff3a82322bce8 /worker/lib | |
parent | fe1cabb077cf6c6cb3de122b3f5532acbeba8c85 (diff) | |
download | aerc-c84630714405a1e93766a6a6c023801302a3ea66.tar.gz |
base models.Address on the mail.Address type
This allows us to hook into the std libs implementation of parsing related stuff. For this, we need to get rid of the distinction between a mailbox and a host to just a single "address" field. However this is already the common case. All but one users immediately concatenated the mbox/domain to a single address. So this in effects makes it simpler for most cases and we simply do the transformation in the special case.
Diffstat (limited to 'worker/lib')
-rw-r--r-- | worker/lib/parse.go | 11 | ||||
-rw-r--r-- | worker/lib/sort.go | 3 |
2 files changed, 2 insertions, 12 deletions
diff --git a/worker/lib/parse.go b/worker/lib/parse.go index 58327c9..b003d96 100644 --- a/worker/lib/parse.go +++ b/worker/lib/parse.go @@ -205,18 +205,9 @@ func parseAddressList(h *mail.Header, key string) ([]*models.Address, error) { return nil, err } for _, addr := range addrs { - parts := strings.Split(addr.Address, "@") - var mbox, host string - if len(parts) > 1 { - mbox = strings.Join(parts[0:len(parts)-1], "@") - host = parts[len(parts)-1] - } else { - mbox = addr.Address - } converted = append(converted, &models.Address{ Name: addr.Name, - Mailbox: mbox, - Host: host, + Address: addr.Address, }) } return converted, nil diff --git a/worker/lib/sort.go b/worker/lib/sort.go index ac8ed07..9d1f50a 100644 --- a/worker/lib/sort.go +++ b/worker/lib/sort.go @@ -1,7 +1,6 @@ package lib import ( - "fmt" "sort" "strings" @@ -83,7 +82,7 @@ func sortAddresses(messageInfos []*models.MessageInfo, criterion *types.SortCrit if addr.Name != "" { return addr.Name } else { - return fmt.Sprintf("%s@%s", addr.Mailbox, addr.Host) + return addr.Address } } return getName(firstI) < getName(firstJ) |