dt-common-device 13.4.2 → 13.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare class EmailService {
|
|
2
2
|
private readonly s3Client;
|
|
3
|
-
private readonly
|
|
3
|
+
private readonly transporter;
|
|
4
4
|
private readonly propertyService;
|
|
5
5
|
constructor();
|
|
6
6
|
getTemplateForProperty(fileName: string, propertyId: string): Promise<import("@aws-sdk/client-s3").GetObjectCommandOutput | undefined>;
|
|
@@ -73,8 +73,8 @@ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, p
|
|
|
73
73
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
74
74
|
exports.EmailService = void 0;
|
|
75
75
|
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
76
|
-
const client_ses_1 = require("@aws-sdk/client-ses");
|
|
77
76
|
const fs = __importStar(require("fs"));
|
|
77
|
+
const nodemailer = __importStar(require("nodemailer"));
|
|
78
78
|
const typedi_1 = __importStar(require("typedi"));
|
|
79
79
|
const Email_1 = require("../constants/Email");
|
|
80
80
|
const Property_service_1 = require("../entities/property/Property.service");
|
|
@@ -92,7 +92,15 @@ let EmailService = (() => {
|
|
|
92
92
|
};
|
|
93
93
|
const region = process.env.AWS_REGION ?? "us-east-1";
|
|
94
94
|
this.s3Client = new client_s3_1.S3Client({ credentials, region });
|
|
95
|
-
this.
|
|
95
|
+
this.transporter = nodemailer.createTransport({
|
|
96
|
+
host: 'smtp.gmail.com',
|
|
97
|
+
port: 587,
|
|
98
|
+
secure: false,
|
|
99
|
+
auth: {
|
|
100
|
+
user: process.env.SMTP_USER,
|
|
101
|
+
pass: process.env.SMTP_PASSWORD,
|
|
102
|
+
},
|
|
103
|
+
});
|
|
96
104
|
this.propertyService = typedi_1.default.get(Property_service_1.LocalPropertyService);
|
|
97
105
|
}
|
|
98
106
|
async getTemplateForProperty(fileName, propertyId) {
|
|
@@ -238,9 +246,8 @@ let EmailService = (() => {
|
|
|
238
246
|
}
|
|
239
247
|
const CONTACT_US_DETAILS = (0, Email_1.getContactUsDetails)();
|
|
240
248
|
const from = CONTACT_US_DETAILS?.FROM_EMAIL_ADDRESS;
|
|
241
|
-
if (!process.env.
|
|
242
|
-
|
|
243
|
-
throw new Error("AWS credentials are not set");
|
|
249
|
+
if (!process.env.SMTP_USER || !process.env.SMTP_PASSWORD) {
|
|
250
|
+
throw new Error("SMTP credentials are not set");
|
|
244
251
|
}
|
|
245
252
|
// Section below is replacing the global variables from template like contact us email, phone and current year.
|
|
246
253
|
const currentYear = new Date().getFullYear().toString();
|
|
@@ -252,28 +259,16 @@ let EmailService = (() => {
|
|
|
252
259
|
.replaceAll("{{logo}}", `${imageURL}`);
|
|
253
260
|
// .replaceAll('{{logo}}', `${logo}`);
|
|
254
261
|
//
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
Html: {
|
|
262
|
-
Charset: "UTF-8",
|
|
263
|
-
Data: finalMessage,
|
|
264
|
-
},
|
|
265
|
-
},
|
|
266
|
-
Subject: {
|
|
267
|
-
Charset: "UTF-8",
|
|
268
|
-
Data: subject,
|
|
269
|
-
},
|
|
270
|
-
},
|
|
271
|
-
Source: from, // SENDER_ADDRESS
|
|
272
|
-
ReplyToAddresses: [CONTACT_US_DETAILS?.TO_EMAIL_ADDRESS],
|
|
262
|
+
const mailOptions = {
|
|
263
|
+
from: `"devicethread™ Inc." <${from}>`,
|
|
264
|
+
to: toAddr,
|
|
265
|
+
subject: subject,
|
|
266
|
+
html: finalMessage,
|
|
267
|
+
replyTo: CONTACT_US_DETAILS?.TO_EMAIL_ADDRESS,
|
|
273
268
|
};
|
|
274
269
|
// Add CC addresses if present
|
|
275
270
|
if (ccAddr && Array.isArray(ccAddr) && ccAddr.length > 0) {
|
|
276
|
-
|
|
271
|
+
mailOptions.cc = ccAddr;
|
|
277
272
|
}
|
|
278
273
|
(0, config_1.getLogger)().info(`sending email with params: ${JSON.stringify(toAddr)}`);
|
|
279
274
|
if (ccAddr && ccAddr.length > 0) {
|
|
@@ -281,10 +276,10 @@ let EmailService = (() => {
|
|
|
281
276
|
}
|
|
282
277
|
mailData.from = CONTACT_US_DETAILS?.FROM_EMAIL_ADDRESS;
|
|
283
278
|
if (pdfBuffer) {
|
|
284
|
-
// this.sendEmailWithAttachments(this.
|
|
279
|
+
// this.sendEmailWithAttachments(this.transporter, mailData, finalMessage, pdfBuffer)
|
|
285
280
|
}
|
|
286
281
|
else {
|
|
287
|
-
await this.
|
|
282
|
+
await this.transporter.sendMail(mailOptions);
|
|
288
283
|
}
|
|
289
284
|
const maskedEmailsList = toAddr.map((email) => (0, Email_1.GetMaskedEmail)(email));
|
|
290
285
|
(0, config_1.getLogger)().info(`Sending email to: ${maskedEmailsList.join(", ")}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dt-common-device",
|
|
3
|
-
"version": "13.4.
|
|
3
|
+
"version": "13.4.4",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/lodash": "^4.17.19",
|
|
40
40
|
"@types/node": "^20.0.0",
|
|
41
|
+
"@types/nodemailer": "7.0.11",
|
|
41
42
|
"@types/pg": "8.15.4",
|
|
42
43
|
"ts-node": "^10.9.2",
|
|
43
44
|
"typescript": "^5.8.3"
|
|
@@ -52,6 +53,7 @@
|
|
|
52
53
|
"ioredis": "5.6.1",
|
|
53
54
|
"lodash": "^4.17.21",
|
|
54
55
|
"mongoose": "8.17.1",
|
|
56
|
+
"nodemailer": "8.0.1",
|
|
55
57
|
"pg": "8.16.3",
|
|
56
58
|
"svix": "1.84.1",
|
|
57
59
|
"twilio": "5.12.2",
|