backend-manager 2.5.28 → 2.5.30
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.json
CHANGED
|
@@ -4,57 +4,54 @@ module.exports = function (payload, config) {
|
|
|
4
4
|
const groupId = 16223;
|
|
5
5
|
|
|
6
6
|
return {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
// spamFilter: {
|
|
8
|
+
// ip: 3,
|
|
9
|
+
// email: 3,
|
|
10
|
+
// },
|
|
11
|
+
// delay: 1,
|
|
10
12
|
body: {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
asm: {
|
|
54
|
-
group_id: 16223,
|
|
55
|
-
},
|
|
56
|
-
categories: ['transactional', 'download', config.app.id],
|
|
57
|
-
}
|
|
13
|
+
personalizations: [
|
|
14
|
+
{
|
|
15
|
+
to: [
|
|
16
|
+
{
|
|
17
|
+
name: payload.name || 'Valued member',
|
|
18
|
+
email: payload.email,
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
dynamic_template_data: {
|
|
22
|
+
subject: subject,
|
|
23
|
+
app: {
|
|
24
|
+
url: config.brand.url,
|
|
25
|
+
name: config.brand.name,
|
|
26
|
+
wordmark: config.brand.wordmark,
|
|
27
|
+
brandmark: config.brand.brandmark,
|
|
28
|
+
combomark: config.brand.combomark,
|
|
29
|
+
},
|
|
30
|
+
footer: {
|
|
31
|
+
name: 'ITW Creative Works',
|
|
32
|
+
address: '4001 Inglewood Ave 101-385',
|
|
33
|
+
city: 'Redondo Beach',
|
|
34
|
+
state: 'CA',
|
|
35
|
+
zip: '90278',
|
|
36
|
+
'unsubscribe-link': `https://itwcreativeworks.com/email-preferences/?email=${encodeURIComponent(payload.email)}&asmId=${encodeURIComponent(groupId)}&templateId=${encodeURIComponent(templateId)}&appName=${encodeURIComponent(config.brand.name)}`,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
from: {
|
|
42
|
+
name: config.brand.name,
|
|
43
|
+
email: config.brand.email,
|
|
44
|
+
},
|
|
45
|
+
reply_to: {
|
|
46
|
+
name: config.brand.name,
|
|
47
|
+
email: config.brand.email,
|
|
48
|
+
},
|
|
49
|
+
subject: subject,
|
|
50
|
+
template_id: 'd-1d730ac8cc544b7cbccc8fa4a4b3f9ce',
|
|
51
|
+
asm: {
|
|
52
|
+
group_id: 16223,
|
|
53
|
+
},
|
|
54
|
+
categories: ['transactional', 'download', config.app.id],
|
|
58
55
|
}
|
|
59
56
|
}
|
|
60
57
|
}
|
|
@@ -23,6 +23,7 @@ Module.prototype.main = function () {
|
|
|
23
23
|
ip: 3,
|
|
24
24
|
email: 3,
|
|
25
25
|
},
|
|
26
|
+
delay: 1,
|
|
26
27
|
body: {},
|
|
27
28
|
}
|
|
28
29
|
|
|
@@ -57,29 +58,34 @@ Module.prototype.main = function () {
|
|
|
57
58
|
storage.set(ipPath, ipData).write();
|
|
58
59
|
storage.set(emailPath, emailData).write();
|
|
59
60
|
|
|
60
|
-
assistant.log('Storage', storage.getState()['api:general:send-email']);
|
|
61
|
+
assistant.log('Storage:', storage.getState()['api:general:send-email'], {environment: 'production'});
|
|
61
62
|
|
|
62
63
|
if (ipData.count >= emailPayload.spamFilter.ip || emailData.count >= emailPayload.spamFilter.email) {
|
|
63
64
|
self.assistant.errorManager(`Spam filter triggered ip=${ipData.count}, email=${emailData.count}`, {code: 429, sentry: false, send: false, log: true})
|
|
64
65
|
return resolve({data: {success: true}});
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
|
|
68
|
+
assistant.log('Email payload:', emailPayload, {environment: 'production'});
|
|
69
|
+
|
|
70
|
+
const sendableBody = {
|
|
71
|
+
backendManagerKey: Manager.config.backend_manager.key,
|
|
72
|
+
service: 'sendgrid',
|
|
73
|
+
command: `v3/mail/send`,
|
|
74
|
+
method: 'post',
|
|
75
|
+
delay: emailPayload.delay,
|
|
76
|
+
body: emailPayload.body,
|
|
77
|
+
}
|
|
68
78
|
|
|
69
79
|
fetch('https://us-central1-itw-creative-works.cloudfunctions.net/wrapper', {
|
|
70
80
|
method: 'post',
|
|
71
81
|
timeout: 30000,
|
|
72
82
|
tries: 1,
|
|
73
83
|
response: 'json',
|
|
74
|
-
body:
|
|
75
|
-
service: 'sendgrid',
|
|
76
|
-
command: `/v3/mail/send`,
|
|
77
|
-
method: 'post',
|
|
78
|
-
body: emailPayload.body,
|
|
79
|
-
},
|
|
84
|
+
body: sendableBody,
|
|
80
85
|
})
|
|
81
|
-
.then(
|
|
82
|
-
|
|
86
|
+
.then(res => {
|
|
87
|
+
assistant.log('Response:', res, {environment: 'production'});
|
|
88
|
+
|
|
83
89
|
return resolve({
|
|
84
90
|
data: {
|
|
85
91
|
success: true,
|
|
@@ -89,9 +95,6 @@ Module.prototype.main = function () {
|
|
|
89
95
|
.catch(e => {
|
|
90
96
|
return reject(assistant.errorManager(`Error sending email: ${e}`, {code: 500, sentry: true, send: false, log: false}).error)
|
|
91
97
|
})
|
|
92
|
-
|
|
93
|
-
// return resolve({data: {success: true}});
|
|
94
|
-
|
|
95
98
|
});
|
|
96
99
|
|
|
97
100
|
};
|