From fda424bebc6dedbbcbffe4d330accc70d081b478 Mon Sep 17 00:00:00 2001 From: Reto Brunner Date: Mon, 22 Feb 2021 11:46:58 +0100 Subject: lib/parse: simplify parseAddressList --- worker/lib/parse.go | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'worker/lib') diff --git a/worker/lib/parse.go b/worker/lib/parse.go index 78525d04..efdb60f6 100644 --- a/worker/lib/parse.go +++ b/worker/lib/parse.go @@ -198,23 +198,15 @@ func parseReceivedHeader(h *mail.Header) (time.Time, error) { } func parseAddressList(h *mail.Header, key string) ([]*mail.Address, error) { - var converted []*mail.Address addrs, err := h.AddressList(key) + if err == nil { + return addrs, nil + } + hdr, err := h.Text(key) if err != nil { - if hdr, err := h.Text(key); err == nil { - return []*mail.Address{&mail.Address{ - Name: hdr, - }}, nil - } return nil, err } - for _, addr := range addrs { - converted = append(converted, &mail.Address{ - Name: addr.Name, - Address: addr.Address, - }) - } - return converted, nil + return []*mail.Address{{Name: hdr}}, nil } // RawMessage is an interface that describes a raw message -- cgit