ag-common 0.0.702 → 0.0.704
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.js
CHANGED
|
@@ -11,14 +11,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.sendEmails = exports.sendEmail = exports.ses = exports.setSes = void 0;
|
|
13
13
|
const client_ses_1 = require("@aws-sdk/client-ses");
|
|
14
|
+
const log_1 = require("../../common/helpers/log");
|
|
14
15
|
const setSes = (region) => {
|
|
15
16
|
const raw = new client_ses_1.SESClient({ region });
|
|
17
|
+
exports.ses = raw;
|
|
16
18
|
return raw;
|
|
17
19
|
};
|
|
18
20
|
exports.setSes = setSes;
|
|
19
21
|
exports.ses = (0, exports.setSes)('ap-southeast-2');
|
|
20
22
|
const sendEmail = (_a) => __awaiter(void 0, [_a], void 0, function* ({ to, message, subject, sourceArn, from, }) {
|
|
23
|
+
var _b;
|
|
21
24
|
try {
|
|
25
|
+
const sourceArnRegion = (_b = sourceArn.match(':ses:(.*?):')) === null || _b === void 0 ? void 0 : _b[1];
|
|
26
|
+
if (sourceArn !== exports.ses.config.region && sourceArnRegion) {
|
|
27
|
+
(0, log_1.warn)('ses arn not equal to config region changing to:' + sourceArnRegion);
|
|
28
|
+
(0, exports.setSes)(sourceArnRegion);
|
|
29
|
+
}
|
|
22
30
|
yield exports.ses.send(new client_ses_1.SendEmailCommand({
|
|
23
31
|
Destination: {
|
|
24
32
|
CcAddresses: [],
|
|
@@ -43,6 +51,7 @@ const sendEmail = (_a) => __awaiter(void 0, [_a], void 0, function* ({ to, messa
|
|
|
43
51
|
return {};
|
|
44
52
|
}
|
|
45
53
|
catch (e) {
|
|
54
|
+
(0, log_1.warn)('ses send error:' + JSON.stringify(e));
|
|
46
55
|
return { error: e.toString() };
|
|
47
56
|
}
|
|
48
57
|
});
|
package/package.json
CHANGED