mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-01-12 04:39:48 -06:00
add testAll
This commit is contained in:
@@ -418,6 +418,29 @@ class NotificationService {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async testAllNotifications(notificationIDs) {
|
||||
const notifications = await this.db.getNotificationsByIds(notificationIDs);
|
||||
|
||||
// Map each notification to a test promise
|
||||
const testPromises = notifications.map(async (notification) => {
|
||||
try {
|
||||
if (notification.type === "email") {
|
||||
await this.sendTestEmail(notification);
|
||||
} else if (notification.type === "webhook") {
|
||||
await this.sendTestWebhookNotification(notification);
|
||||
} else if (notification.type === "pager_duty") {
|
||||
await this.sendTestPagerDutyNotification(notification);
|
||||
}
|
||||
return true;
|
||||
} catch (err) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
const results = await Promise.all(testPromises);
|
||||
return results.every((r) => r === true);
|
||||
}
|
||||
}
|
||||
|
||||
export default NotificationService;
|
||||
|
||||
Reference in New Issue
Block a user