fix: issue in mail sender.

This commit is contained in:
a.bouhuolia
2020-12-17 01:16:08 +02:00
parent 3ac6d8897e
commit 46d06bd591
32 changed files with 538 additions and 334 deletions

View File

@@ -2,19 +2,31 @@ import { Container } from 'typedi';
import LicenseService from 'services/Payment/License';
export default class SendLicenseViaEmailJob {
/**
* Constructor method.
* @param agenda
*/
constructor(agenda) {
agenda.define(
'send-license-via-email',
{ priority: 'high', concurrency: 1, },
this.handler,
);
}
public async handler(job, done: Function): Promise<void> {
const Logger = Container.get('logger');
const licenseService = Container.get(LicenseService);
const { email, licenseCode } = job.attrs.data;
Logger.debug(`Send license via email - started: ${job.attrs.data}`);
Logger.info(`[send_license_via_mail] started: ${job.attrs.data}`);
try {
await licenseService.mailMessages.sendMailLicense(licenseCode, email);
Logger.debug(`Send license via email - completed: ${job.attrs.data}`);
Logger.info(`[send_license_via_mail] completed: ${job.attrs.data}`);
done();
} catch(e) {
Logger.error(`Send license via email: ${job.attrs.data}, error: ${e}`);
Logger.error(`[send_license_via_mail] ${job.attrs.data}, error: ${e}`);
done(e);
}
}