0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

🐛 Fixed newsletters being sent to Stripe customer emails in place of member emails

no issue

- the paid-member SQL query that is obtained using `models.Member.getFilteredCollectionQuery({paid: true})` can return multiple columns with the same name (eg, `email`, `name`), when that happens the last column with duplicate names "wins" and it's value is used in the resulting knex row instance
- in the `mega` service when fetching email recipient rows we ran into this problem, to avoid it we adjust the query to explicitly select only the data from the `members` table
This commit is contained in:
Kevin Ansfield 2020-10-02 12:17:17 +01:00
parent 82126f29e6
commit 7b789e1cd5

View file

@ -253,7 +253,9 @@ async function getEmailMemberRows({emailModel, options}) {
const startRetrieve = Date.now();
debug('getEmailMemberRows: retrieving members list');
const memberRows = await models.Member.getFilteredCollectionQuery(filterOptions);
// select('members.*') is necessary here to avoid duplicate `email` columns in the result set
// without it we do `select *` which pulls in the Stripe customer email too which overrides the member email
const memberRows = await models.Member.getFilteredCollectionQuery(filterOptions).select('members.*');
debug(`getEmailMemberRows: retrieved members list - ${memberRows.length} members (${Date.now() - startRetrieve}ms)`);
return memberRows;