From 52d5a314deacf642b7e448129f87141167b5aeea Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Tue, 21 Jul 2026 04:57:48 +0200 Subject: [PATCH] Fixed failed Resend initialization crashing entire application. --- src/alerts.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/alerts.js b/src/alerts.js index 721eec5..2de906a 100755 --- a/src/alerts.js +++ b/src/alerts.js @@ -15,7 +15,18 @@ import { indexApi } from './manticore.js'; import { fetchScenesById } from './scenes.js'; const logger = initLogger(); -const resend = new Resend(config.email.apiKey); +const resend = (() => { + if (config.email.enabled) { + try { + return new Resend(config.email.apiKey); + } + catch (error) { + logger.error(`Failed to initialize Resend: ${error.message}`); + } + } + + return null; +})(); function getImagePath(media) { if (!media) { @@ -437,7 +448,7 @@ const frequencies = { }; async function sendEmailAlerts() { - if (!config.email.enabled) { + if (!config.email.enabled || !resend) { return; }