mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
34 lines
935 B
TypeScript
34 lines
935 B
TypeScript
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.info(`[send_license_via_mail] started: ${job.attrs.data}`);
|
|
|
|
try {
|
|
await licenseService.mailMessages.sendMailLicense(licenseCode, email);
|
|
Logger.info(`[send_license_via_mail] completed: ${job.attrs.data}`);
|
|
done();
|
|
} catch(e) {
|
|
Logger.error(`[send_license_via_mail] ${job.attrs.data}, error: ${e}`);
|
|
done(e);
|
|
}
|
|
}
|
|
}
|