summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorReto Brunner <reto@labrat.space>2021-02-22 11:46:58 +0100
committerReto Brunner <reto@labrat.space>2021-02-22 11:47:31 +0100
commitfda424bebc6dedbbcbffe4d330accc70d081b478 (patch)
tree525ce322505a1e82a29c5aff3ed94d4f252624f3
parentc06a2e61fc32051d429dbbaf4dc3cc0019f4a69c (diff)
downloadaerc-fda424bebc6dedbbcbffe4d330accc70d081b478.tar.gz
lib/parse: simplify parseAddressList
-rw-r--r--worker/lib/parse.go18
1 files changed, 5 insertions, 13 deletions
diff --git a/worker/lib/parse.go b/worker/lib/parse.go
index 78525d0..efdb60f 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
>143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216