@plusscommunities/pluss-maintenance-aws 1.2.1 → 1.2.2
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.
- package/package-lock.json +1 -1
- package/package.json +1 -1
- package/sendJobEmail.js +38 -27
package/package-lock.json
CHANGED
package/package.json
CHANGED
package/sendJobEmail.js
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
const _ = require("lodash");
|
|
2
2
|
const getJobEmail = require("./db/maintenance/getJobEmail");
|
|
3
3
|
const sendEmail = require("@plusscommunities/pluss-core-aws/helper/sendEmail");
|
|
4
|
+
const getRef = require("@plusscommunities/pluss-core-aws/db/common/getRef");
|
|
4
5
|
|
|
5
6
|
module.exports = function (job, updated) {
|
|
6
7
|
const whenEvs = job.isHome
|
|
7
8
|
? "Yes - I would like to be present"
|
|
8
9
|
: "No - Work may be done while I am not home.";
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
getRef("sites", "Id", job.site || job.location)
|
|
12
|
+
.then((site) => {
|
|
13
|
+
const siteToUse = site ? site.siteName : job.site || job.location;
|
|
14
|
+
|
|
15
|
+
let htmlString = `
|
|
11
16
|
<div>
|
|
12
17
|
<p><b>Service Request ${job.id != null ? `#${job.id}` : ""}${
|
|
13
|
-
|
|
14
|
-
|
|
18
|
+
updated ? "-DETAILS EDITED- " : " "
|
|
19
|
+
}(${job.type}):</b> ${job.room}</p>
|
|
15
20
|
<div>
|
|
16
21
|
<b>Title: </b>${job.title}
|
|
17
22
|
</div>
|
|
@@ -23,7 +28,7 @@ module.exports = function (job, updated) {
|
|
|
23
28
|
<b>Phone: </b>${job.phone}
|
|
24
29
|
</div>
|
|
25
30
|
<div>
|
|
26
|
-
<b>Location: </b>${
|
|
31
|
+
<b>Location: </b>${siteToUse} <br /><br />
|
|
27
32
|
</div>
|
|
28
33
|
<div>
|
|
29
34
|
<b>Address: </b>${job.room} <br /><br />
|
|
@@ -43,12 +48,12 @@ module.exports = function (job, updated) {
|
|
|
43
48
|
</div>
|
|
44
49
|
</div>`;
|
|
45
50
|
|
|
46
|
-
|
|
47
|
-
|
|
51
|
+
if (!_.isNil(job.images) || !_.isNil(job.image)) {
|
|
52
|
+
htmlString = `
|
|
48
53
|
<div>
|
|
49
54
|
<p><b>Service Request ${job.id != null ? `#${job.id}` : ""}${
|
|
50
|
-
|
|
51
|
-
|
|
55
|
+
updated ? "-DETAILS EDITED- " : " "
|
|
56
|
+
}(${job.type}):</b> ${job.room}</p>
|
|
52
57
|
<div>
|
|
53
58
|
<b>Title: </b>${job.title}
|
|
54
59
|
</div>
|
|
@@ -60,7 +65,7 @@ module.exports = function (job, updated) {
|
|
|
60
65
|
<b>Phone: </b>${job.phone}
|
|
61
66
|
</div>
|
|
62
67
|
<div>
|
|
63
|
-
<b>Location: </b>${
|
|
68
|
+
<b>Location: </b>${siteToUse} <br /><br />
|
|
64
69
|
</div>
|
|
65
70
|
<div>
|
|
66
71
|
<b>Address: </b>${job.room} <br /><br />
|
|
@@ -89,33 +94,39 @@ module.exports = function (job, updated) {
|
|
|
89
94
|
}
|
|
90
95
|
<div>
|
|
91
96
|
</div>`;
|
|
92
|
-
|
|
97
|
+
}
|
|
93
98
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
99
|
+
getJobEmail(job.site || job.location, job.type)
|
|
100
|
+
.then((obj) => {
|
|
101
|
+
const email = obj.email;
|
|
97
102
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
103
|
+
sendEmail(
|
|
104
|
+
email,
|
|
105
|
+
`Service Request #${job.id}${updated ? " -DETAILS EDITED" : ""}- (${
|
|
106
|
+
job.type
|
|
107
|
+
}) - ${job.room}`,
|
|
108
|
+
htmlString
|
|
109
|
+
)
|
|
110
|
+
.then((result) => {
|
|
111
|
+
console.log(
|
|
112
|
+
`SUCCESS - Maintenance email --> ${job.type}, ${job.userName}`
|
|
113
|
+
);
|
|
114
|
+
})
|
|
115
|
+
.catch((error) => {
|
|
116
|
+
console.log(
|
|
117
|
+
`FAIL - Maintenance email --> ${job.type}, ${job.userName}`
|
|
118
|
+
);
|
|
119
|
+
});
|
|
109
120
|
})
|
|
110
|
-
.catch((
|
|
121
|
+
.catch(() => {
|
|
111
122
|
console.log(
|
|
112
|
-
`FAIL - Maintenance email --> ${job.type}, ${job.userName}`
|
|
123
|
+
`FAIL - Maintenance email - fetch email address --> ${job.type}, ${job.userName}`
|
|
113
124
|
);
|
|
114
125
|
});
|
|
115
126
|
})
|
|
116
127
|
.catch(() => {
|
|
117
128
|
console.log(
|
|
118
|
-
`FAIL - Maintenance email - fetch
|
|
129
|
+
`FAIL - Maintenance email - fetch site --> ${job.site || job.location}`
|
|
119
130
|
);
|
|
120
131
|
});
|
|
121
132
|
};
|