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);
}
}

View File

@@ -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;

View File

@@ -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

View File

@@ -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);
}
}