TASK22224: aggressive non-file parity bundle
This commit is contained in:
+14
-15
@@ -31,7 +31,7 @@ import { getPreferredLanguage } from "../../../actions/services/accountService";
|
||||
import { respondError, respondSuccess } from "../middleware/apiResponse";
|
||||
|
||||
export default async function ApiProxy(req, res) {
|
||||
var data = req.body;
|
||||
const data = req.body;
|
||||
const emailAddress = sanitizeString(data?.emailAddress);
|
||||
|
||||
if (!isNonEmptyString(emailAddress)) {
|
||||
@@ -58,7 +58,7 @@ export default async function ApiProxy(req, res) {
|
||||
}
|
||||
}
|
||||
|
||||
var NotifyClient = require("notifications-node-client").NotifyClient;
|
||||
const NotifyClient = require("notifications-node-client").NotifyClient;
|
||||
|
||||
const notifyClient = new NotifyClient(process.env.NOTIFY_API_KEY);
|
||||
//const emailReplyToId = process.env.EMAIL_REPLY_TO_ID;
|
||||
@@ -68,20 +68,19 @@ export default async function ApiProxy(req, res) {
|
||||
payload: redactSensitive(data)
|
||||
});
|
||||
|
||||
notifyClient
|
||||
.sendEmail(data.templateId, data.emailAddress, {
|
||||
try {
|
||||
await notifyClient.sendEmail(data.templateId, data.emailAddress, {
|
||||
personalisation: data.personalisation,
|
||||
reference: data.reference
|
||||
})
|
||||
.then(() => {
|
||||
return respondSuccess(res, data);
|
||||
})
|
||||
.catch((error) => {
|
||||
consoleLogger(error);
|
||||
return respondError(res, {
|
||||
status: 400,
|
||||
code: "EMAIL_NOTIFY_FAILED",
|
||||
message: "Failed to send notify email"
|
||||
});
|
||||
});
|
||||
|
||||
return respondSuccess(res, data);
|
||||
} catch (error) {
|
||||
consoleLogger(error);
|
||||
return respondError(res, {
|
||||
status: 400,
|
||||
code: "EMAIL_NOTIFY_FAILED",
|
||||
message: "Failed to send notify email"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user