ag-common 0.0.703 → 0.0.705
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/dist/api/helpers/ses.d.ts +1 -1
- package/dist/api/helpers/ses.js +12 -4
- package/package.json +1 -1
package/dist/api/helpers/ses.js
CHANGED
|
@@ -14,6 +14,7 @@ const client_ses_1 = require("@aws-sdk/client-ses");
|
|
|
14
14
|
const log_1 = require("../../common/helpers/log");
|
|
15
15
|
const setSes = (region) => {
|
|
16
16
|
const raw = new client_ses_1.SESClient({ region });
|
|
17
|
+
exports.ses = raw;
|
|
17
18
|
return raw;
|
|
18
19
|
};
|
|
19
20
|
exports.setSes = setSes;
|
|
@@ -23,21 +24,27 @@ const sendEmail = (_a) => __awaiter(void 0, [_a], void 0, function* ({ to, messa
|
|
|
23
24
|
try {
|
|
24
25
|
const sourceArnRegion = (_b = sourceArn.match(':ses:(.*?):')) === null || _b === void 0 ? void 0 : _b[1];
|
|
25
26
|
if (sourceArn !== exports.ses.config.region && sourceArnRegion) {
|
|
26
|
-
(0, log_1.warn)('ses arn not equal to config
|
|
27
|
+
(0, log_1.warn)('ses arn not equal to config region changing to:' + sourceArnRegion);
|
|
27
28
|
(0, exports.setSes)(sourceArnRegion);
|
|
28
29
|
}
|
|
30
|
+
const ishtml = message.startsWith('<!DOCTYPE HTML') || message.startsWith('<html');
|
|
29
31
|
yield exports.ses.send(new client_ses_1.SendEmailCommand({
|
|
30
32
|
Destination: {
|
|
31
33
|
CcAddresses: [],
|
|
32
34
|
ToAddresses: [to],
|
|
33
35
|
},
|
|
34
36
|
Message: {
|
|
35
|
-
Body: {
|
|
36
|
-
|
|
37
|
+
Body: Object.assign(Object.assign({}, (ishtml && {
|
|
38
|
+
Html: {
|
|
39
|
+
Data: message,
|
|
37
40
|
Charset: 'UTF-8',
|
|
41
|
+
},
|
|
42
|
+
})), (!ishtml && {
|
|
43
|
+
Text: {
|
|
38
44
|
Data: message,
|
|
45
|
+
Charset: 'UTF-8',
|
|
39
46
|
},
|
|
40
|
-
},
|
|
47
|
+
})),
|
|
41
48
|
Subject: {
|
|
42
49
|
Charset: 'UTF-8',
|
|
43
50
|
Data: subject,
|
|
@@ -50,6 +57,7 @@ const sendEmail = (_a) => __awaiter(void 0, [_a], void 0, function* ({ to, messa
|
|
|
50
57
|
return {};
|
|
51
58
|
}
|
|
52
59
|
catch (e) {
|
|
60
|
+
(0, log_1.warn)('ses send error:' + JSON.stringify(e));
|
|
53
61
|
return { error: e.toString() };
|
|
54
62
|
}
|
|
55
63
|
});
|
package/package.json
CHANGED