Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private async handleEvent(
handler: EmailEventHandler | EmailEventHandlerWithAsyncData,
event: EventWithContext,
) {
Logger.debug(`Handling event "${handler.type}"`, 'EmailPlugin');
const { type } = handler;
try {
if (handler instanceof EmailEventHandlerWithAsyncData) {
(event as EventWithAsyncData).data = await handler._loadDataFn({
event,
connection: this.connection,
inject: t => this.moduleRef.get(t, { strict: false }),
});
}
const result = await handler.handle(event as any, EmailPlugin.options.globalTemplateVars);
if (!result) {
return;
}
const bodySource = await this.templateLoader.loadTemplate(type, result.templateFile);
const generated = await this.generator.generate(
result.from,
body.items.forEach(item => {
if (item.index) {
Logger.debug(JSON.stringify(item.index.error, null, 2), loggerCtx);
}
if (item.update) {
Logger.debug(JSON.stringify(item.update.error, null, 2), loggerCtx);
}
if (item.delete) {
Logger.debug(JSON.stringify(item.delete.error, null, 2), loggerCtx);
}
});
} else {