Skip to content

Commit 4bc9f5f

Browse files
janekhuongtektaxi
authored andcommitted
Cleaner code
1 parent 22ef0ee commit 4bc9f5f

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

services/email.service.js

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,35 @@ class EmailService {
2323
//Silence all actual emails if we're testing
2424
mailData.mailSettings = {
2525
sandboxMode: {
26-
enable: true
27-
}
26+
enable: true,
27+
},
2828
};
2929
}
30-
return client.send(mailData, false)
31-
.then(response => {
32-
callback()
33-
return response
34-
})
35-
.catch(error => {
36-
callback(error)
30+
return client
31+
.send(mailData, false)
32+
.then((response) => {
33+
callback();
34+
return response;
3735
})
36+
.catch((error) => {
37+
callback(error);
38+
});
3839
}
3940
/**
4041
* Send separate emails to the list of users in mailData
4142
* @param {*} mailData
4243
* @param {(err?)=>void} callback
4344
*/
4445
sendMultiple(mailData, callback = () => {}) {
45-
return client.sendMultiple(mailData)
46-
.then(response => {
47-
callback()
46+
return client
47+
.sendMultiple(mailData)
48+
.then((response) => {
49+
callback();
4850
return response;
4951
})
50-
.catch(error => {
51-
callback(error)
52-
})
52+
.catch((error) => {
53+
callback(error);
54+
});
5355
}
5456
/**
5557
* Send email with ticket.
@@ -61,17 +63,17 @@ class EmailService {
6163
sendWeekOfEmail(firstName, recipient, ticket, callback) {
6264
const handlebarsPath = path.join(
6365
__dirname,
64-
`../assets/email/Ticket.hbs`
66+
`../assets/email/Ticket.hbs`,
6567
);
6668
const html = this.renderEmail(handlebarsPath, {
6769
firstName: firstName,
68-
ticket: ticket
70+
ticket: ticket,
6971
});
7072
const mailData = {
7173
to: recipient,
7274
from: process.env.NO_REPLY_EMAIL,
7375
subject: Constants.EMAIL_SUBJECTS[Constants.WEEK_OF],
74-
html: html
76+
html: html,
7577
};
7678
this.send(mailData).then((response) => {
7779
if (
@@ -93,16 +95,16 @@ class EmailService {
9395
sendDayOfEmail(firstName, recipient, callback) {
9496
const handlebarsPath = path.join(
9597
__dirname,
96-
`../assets/email/Welcome.hbs`
98+
`../assets/email/Welcome.hbs`,
9799
);
98100
const html = this.renderEmail(handlebarsPath, {
99-
firstName: firstName
101+
firstName: firstName,
100102
});
101103
const mailData = {
102104
to: recipient,
103105
from: process.env.NO_REPLY_EMAIL,
104106
subject: Constants.EMAIL_SUBJECTS[Constants.WEEK_OF],
105-
html: html
107+
html: html,
106108
};
107109
this.send(mailData).then((response) => {
108110
if (
@@ -119,15 +121,15 @@ class EmailService {
119121
sendStatusUpdate(firstName, recipient, status, callback) {
120122
const handlebarsPath = path.join(
121123
__dirname,
122-
`../assets/email/statusEmail/${status}.hbs`
124+
`../assets/email/statusEmail/${status}.hbs`,
123125
);
124126
const mailData = {
125127
to: recipient,
126128
from: process.env.NO_REPLY_EMAIL,
127129
subject: Constants.EMAIL_SUBJECTS[status],
128130
html: this.renderEmail(handlebarsPath, {
129-
firstName: firstName
130-
})
131+
firstName: firstName,
132+
}),
131133
};
132134
this.send(mailData).then((response) => {
133135
if (

0 commit comments

Comments
 (0)