parent
							
								
									92e8e1708a
								
							
						
					
					
						commit
						ed01d6bc14
					
				|  | @ -177,7 +177,12 @@ func (m *mailer) resolveDestinations() ([]string, error) { | ||||||
| 			if strings.TrimSpace(email) == "" { | 			if strings.TrimSpace(email) == "" { | ||||||
| 				continue | 				continue | ||||||
| 			} | 			} | ||||||
| 			contactsList = append(contactsList, email) | 			parsedEmail, err := mail.ParseAddress(email) | ||||||
|  | 			if err != nil { | ||||||
|  | 				m.log.Errf("unparseable email for reg ID %d : %q", c.ID, email) | ||||||
|  | 				continue | ||||||
|  | 			} | ||||||
|  | 			contactsList = append(contactsList, parsedEmail.Address) | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	return contactsList, nil | 	return contactsList, nil | ||||||
|  |  | ||||||
|  | @ -338,6 +338,10 @@ func (bs mockEmailResolver) SelectOne(output interface{}, _ string, args ...inte | ||||||
| 			ID:      6, | 			ID:      6, | ||||||
| 			Contact: []byte(`["mailto:mail@example.com"]`), | 			Contact: []byte(`["mailto:mail@example.com"]`), | ||||||
| 		}, | 		}, | ||||||
|  | 		{ | ||||||
|  | 			ID:      7, | ||||||
|  | 			Contact: []byte(`["mailto:***********"]`), | ||||||
|  | 		}, | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// Play the type cast game so that we can dig into the arguments map and get
 | 	// Play the type cast game so that we can dig into the arguments map and get
 | ||||||
|  | @ -391,6 +395,11 @@ func TestResolveEmails(t *testing.T) { | ||||||
| 		{ | 		{ | ||||||
| 			ID: 999, | 			ID: 999, | ||||||
| 		}, | 		}, | ||||||
|  | 		// This registration ID deliberately returns an invalid email to make sure any
 | ||||||
|  | 		// invalid contact info that slipped into the DB once upon a time will be ignored
 | ||||||
|  | 		{ | ||||||
|  | 			ID: 7, | ||||||
|  | 		}, | ||||||
| 	} | 	} | ||||||
| 	contactsJSON, err := json.Marshal(regs) | 	contactsJSON, err := json.Marshal(regs) | ||||||
| 	test.AssertNotError(t, err, "failed to marshal test regs") | 	test.AssertNotError(t, err, "failed to marshal test regs") | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue