add tests notification for email

This commit is contained in:
Alex Holliday committed 2025-06-10 13:20:44 +08:00
1 parent e6493df881
commit c20b8c665a
2 files changed
+19 -1

No files matched your search

+1 -1
View File
@@ -90,7 +90,7 @@ class NotificationController {
const notification = req.body;
if (notification?.type === "email") {
console.log("HANDLE EMAIL");
const result = await this.notificationService.sendTestEmail(notification);
return res.success({
msg: this.stringService.emailSendSuccess,
});
+18
View File
@@ -196,6 +196,24 @@ class NotificationService {
return true;
}
sendTestEmail = async (notification) => {
const to = notification?.address;
if (!to || typeof to !== "string") {
throw new Error(this.stringService.errorForValidEmailAddress);
}
const subject = this.stringService.testEmailSubject;
const context = { testName: "Monitoring System" };
const messageId = await this.emailService.buildAndSendEmail(
"testEmailTemplate",
context,
to,
subject
);
console.log(messageId);
};
/**
* Sends an email notification about monitor status change
*