add testAll
This commit is contained in:
1 parent
959f265617
commit
ca4da6d485
1 file changed
+23
@@ -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;
|
export default NotificationService;
|
||||||
Reference in new issue
Block a user