Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Commit

Permalink
Merge pull request #2698 from mozilla/pb/fix-notification-format
Browse files Browse the repository at this point in the history
#2698
r=shane-tomlinson
  • Loading branch information
philbooth committed Oct 29, 2018
2 parents 4d4e843 + ec3ff7b commit dbde76a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 22 deletions.
8 changes: 2 additions & 6 deletions lib/email/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ module.exports = (log, error) => {

let addresses = [], eventType = 'bounced', isDeletionCandidate = false
if (message.bounce) {
addresses = mapBounceComplaintRecipients(message.bounce.bouncedRecipients)
addresses = message.bounce.bouncedRecipients
isDeletionCandidate = true
} else if (message.complaint) {
addresses = mapBounceComplaintRecipients(message.complaint.complainedRecipients)
addresses = message.complaint.complainedRecipients
isDeletionCandidate = true
} else if (message.delivery) {
addresses = message.delivery.recipients
Expand Down Expand Up @@ -57,7 +57,3 @@ module.exports = (log, error) => {
})
}
}

function mapBounceComplaintRecipients (recipients) {
return recipients.map(recipient => recipient.emailAddress)
}
22 changes: 6 additions & 16 deletions test/local/email/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('lib/email/notifications:', () => {
}
},
bounce: {
bouncedRecipients: [ { emailAddress: 'wibble@example.com' } ]
bouncedRecipients: [ 'wibble@example.com' ]
}
})
})
Expand Down Expand Up @@ -136,10 +136,7 @@ describe('lib/email/notifications:', () => {
}
},
complaint: {
complainedRecipients: [
{ emailAddress: 'foo@example.com' },
{ emailAddress: 'pmbooth@gmail.com' }
]
complainedRecipients: [ 'foo@example.com', 'pmbooth@gmail.com' ]
}
})
})
Expand Down Expand Up @@ -234,10 +231,7 @@ describe('lib/email/notifications:', () => {
}
},
bounce: {
bouncedRecipients: [
{ emailAddress: 'wibble@example.com' },
{ emailAddress: 'blee@example.com' }
]
bouncedRecipients: [ 'wibble@example.com', 'blee@example.com' ]
}
})
})
Expand Down Expand Up @@ -309,9 +303,7 @@ describe('lib/email/notifications:', () => {
}
},
complaint: {
complainedRecipients: [
{ emailAddress: 'foo@example.com' }
]
complainedRecipients: [ 'foo@example.com' ]
}
})
})
Expand Down Expand Up @@ -351,9 +343,7 @@ describe('lib/email/notifications:', () => {
}
},
bounce: {
bouncedRecipients: [
{ emailAddress: 'wibble@example.com' }
]
bouncedRecipients: [ 'wibble@example.com' ]
}
})
})
Expand Down Expand Up @@ -444,7 +434,7 @@ describe('lib/email/notifications:', () => {
del,
mail: {},
bounce: {
bouncedRecipients: [ { emailAddress: 'wibble@example.com' } ]
bouncedRecipients: [ 'wibble@example.com' ]
}
})
})
Expand Down

0 comments on commit dbde76a

Please sign in to comment.