text changes and remove infra folder
This commit is contained in:
@@ -11,7 +11,7 @@ let sesClient = null;
|
||||
function getSESClient() {
|
||||
if (!sesClient) {
|
||||
sesClient = new SESClient({
|
||||
region: process.env.AWS_REGION || "us-east-1",
|
||||
region: process.env.AWS_REGION,
|
||||
});
|
||||
}
|
||||
return sesClient;
|
||||
@@ -69,12 +69,14 @@ async function loadTemplate(templatePath) {
|
||||
try {
|
||||
return await fs.readFile(templatePath, "utf-8");
|
||||
} catch (error) {
|
||||
console.error(JSON.stringify({
|
||||
level: "error",
|
||||
message: "Failed to load email template",
|
||||
templatePath,
|
||||
error: error.message,
|
||||
}));
|
||||
console.error(
|
||||
JSON.stringify({
|
||||
level: "error",
|
||||
message: "Failed to load email template",
|
||||
templatePath,
|
||||
error: error.message,
|
||||
}),
|
||||
);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -90,12 +92,14 @@ async function loadTemplate(templatePath) {
|
||||
async function sendEmail(to, subject, htmlBody, textBody = null) {
|
||||
// Check if email sending is enabled
|
||||
if (process.env.EMAIL_ENABLED !== "true") {
|
||||
console.log(JSON.stringify({
|
||||
level: "info",
|
||||
message: "Email sending disabled, skipping",
|
||||
to,
|
||||
subject,
|
||||
}));
|
||||
console.log(
|
||||
JSON.stringify({
|
||||
level: "info",
|
||||
message: "Email sending disabled, skipping",
|
||||
to,
|
||||
subject,
|
||||
}),
|
||||
);
|
||||
return { success: true, messageId: "disabled" };
|
||||
}
|
||||
|
||||
@@ -146,23 +150,27 @@ async function sendEmail(to, subject, htmlBody, textBody = null) {
|
||||
const command = new SendEmailCommand(params);
|
||||
const result = await client.send(command);
|
||||
|
||||
console.log(JSON.stringify({
|
||||
level: "info",
|
||||
message: "Email sent successfully",
|
||||
to,
|
||||
subject,
|
||||
messageId: result.MessageId,
|
||||
}));
|
||||
console.log(
|
||||
JSON.stringify({
|
||||
level: "info",
|
||||
message: "Email sent successfully",
|
||||
to,
|
||||
subject,
|
||||
messageId: result.MessageId,
|
||||
}),
|
||||
);
|
||||
|
||||
return { success: true, messageId: result.MessageId };
|
||||
} catch (error) {
|
||||
console.error(JSON.stringify({
|
||||
level: "error",
|
||||
message: "Failed to send email",
|
||||
to,
|
||||
subject,
|
||||
error: error.message,
|
||||
}));
|
||||
console.error(
|
||||
JSON.stringify({
|
||||
level: "error",
|
||||
message: "Failed to send email",
|
||||
to,
|
||||
subject,
|
||||
error: error.message,
|
||||
}),
|
||||
);
|
||||
|
||||
return { success: false, error: error.message };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user