Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[email-plugin] Filters don't work when loadData used #257

Closed
michaelbromley opened this issue Feb 6, 2020 · 0 comments
Closed

[email-plugin] Filters don't work when loadData used #257

michaelbromley opened this issue Feb 6, 2020 · 0 comments
Assignees
Labels
type: bug 🐛 Something isn't working

Comments

@michaelbromley
Copy link
Member

Describe the bug
When defining an EmailEventHandler, if the loadData method is used after the filter method, then the filters no longer work.

To Reproduce

const handler = new EmailEventListener('test')
                .on(MockEvent)
                .filter(event => event.shouldSend === true)
                .loadData(context => Promise.resolve('loaded data'))
                .setRecipient(() => '[email protected]')
                .setFrom('"test from" <[email protected]>')
                .setSubject('test subject');

Expected behavior
Filters should still work

Environment (please complete the following information):

  • @vendure/core version: 0.8.1
  • Nodejs version: 12.4.0
  • Database (mysql/postgres etc): any

Additional context
The cause seems to be due to this:

loadData<R>(
loadDataFn: LoadDataFn<Event, R>,
): EmailEventHandlerWithAsyncData<R, T, Event, EventWithAsyncData<Event, R>> {
return new EmailEventHandlerWithAsyncData(loadDataFn, this.listener, this.event);
}

When the EmailEventHandlerWithAsyncData is created, the this.filterFns array is not passed on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant