@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plusscommunities/pluss-maintenance-aws",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "lockfileVersion": 1,
5
5
  "requires": true,
6
6
  "dependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plusscommunities/pluss-maintenance-aws",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "Extension package to enable maintenance on Pluss Communities Platform",
5
5
  "scripts": {
6
6
  "gc": "node ../../tools/gc ./",
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
- let htmlString = `
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
- updated ? "-DETAILS EDITED- " : " "
14
- }(${job.type}):</b> ${job.room}</p>
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>${job.site || job.location} <br /><br />
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
- if (!_.isNil(job.images) || !_.isNil(job.image)) {
47
- htmlString = `
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
- updated ? "-DETAILS EDITED- " : " "
51
- }(${job.type}):</b> ${job.room}</p>
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>${job.site || job.location} <br /><br />
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
- getJobEmail(job.site || job.location, job.type)
95
- .then((obj) => {
96
- const email = obj.email;
99
+ getJobEmail(job.site || job.location, job.type)
100
+ .then((obj) => {
101
+ const email = obj.email;
97
102
 
98
- sendEmail(
99
- email,
100
- `Service Request #${job.id}${updated ? " -DETAILS EDITED" : ""}- (${
101
- job.type
102
- }) - ${job.room}`,
103
- htmlString
104
- )
105
- .then((result) => {
106
- console.log(
107
- `SUCCESS - Maintenance email --> ${job.type}, ${job.userName}`
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((error) => {
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 email address --> ${job.type}, ${job.userName}`
129
+ `FAIL - Maintenance email - fetch site --> ${job.site || job.location}`
119
130
  );
120
131
  });
121
132
  };