add tests notification for email
This commit is contained in:
1 parent
e6493df881
commit
c20b8c665a
2 files changed
+19
-1
No files matched your search
@@ -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,
|
||||
});
|
||||
|
||||
@@ -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
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user