mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 14:20:31 +00:00
fix: issue in mail sender.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,17 @@ import { Container } from 'typedi';
|
||||
import LicenseService from 'services/Payment/License';
|
||||
|
||||
export default class SendLicenseViaPhoneJob {
|
||||
/**
|
||||
* Constructor method.
|
||||
*/
|
||||
constructor(agenda) {
|
||||
agenda.define(
|
||||
'send-license-via-phone',
|
||||
{ priority: 'high', concurrency: 1, },
|
||||
this.handler,
|
||||
);
|
||||
}
|
||||
|
||||
public async handler(job, done: Function): Promise<void> {
|
||||
const { phoneNumber, licenseCode } = job.attrs.data;
|
||||
|
||||
|
||||
@@ -5,6 +5,18 @@ export default class UserInviteMailJob {
|
||||
@Inject()
|
||||
inviteUsersService: InviteUserService;
|
||||
|
||||
/**
|
||||
* Constructor method.
|
||||
* @param {Agenda} agenda
|
||||
*/
|
||||
constructor(agenda) {
|
||||
agenda.define(
|
||||
'user-invite-mail',
|
||||
{ priority: 'high' },
|
||||
this.handler.bind(this),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle invite user job.
|
||||
* @param {Job} job
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Container, Inject } from 'typedi';
|
||||
import { Container } from 'typedi';
|
||||
import AuthenticationService from 'services/Authentication';
|
||||
|
||||
export default class WelcomeEmailJob {
|
||||
@@ -21,18 +21,18 @@ export default class WelcomeEmailJob {
|
||||
* @param {Function} done
|
||||
*/
|
||||
public async handler(job, done: Function): Promise<void> {
|
||||
const { organizationName, user } = job.attrs.data;
|
||||
const { organizationId, user } = job.attrs.data;
|
||||
const Logger: any = Container.get('logger');
|
||||
const authService = Container.get(AuthenticationService);
|
||||
|
||||
Logger.info(`[welcome_mail] send welcome mail message - started: ${job.attrs.data}`);
|
||||
Logger.info(`[welcome_mail] started: ${job.attrs.data}`);
|
||||
|
||||
try {
|
||||
await authService.mailMessages.sendWelcomeMessage(user, organizationName);
|
||||
Logger.info(`[welcome_mail] send welcome mail message - finished: ${job.attrs.data}`);
|
||||
await authService.mailMessages.sendWelcomeMessage(user, organizationId);
|
||||
Logger.info(`[welcome_mail] finished: ${job.attrs.data}`);
|
||||
done();
|
||||
} catch (error) {
|
||||
Logger.info(`[welcome_mail] send welcome mail message - error: ${job.attrs.data}, error: ${error}`);
|
||||
Logger.error(`[welcome_mail] error: ${job.attrs.data}, error: ${error}`);
|
||||
done(error);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user