From a9dadb9a53da6f889ee0cd5fcd4a05b4533d4179 Mon Sep 17 00:00:00 2001 From: Ravinou Date: Sat, 12 Apr 2025 16:57:18 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20handle=20Apprise=20to=20f?= =?UTF-8?q?ail=20gracefully=20on=20check=20status?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/api/cronjob/checkStatus.ts | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/pages/api/cronjob/checkStatus.ts b/pages/api/cronjob/checkStatus.ts index 9fb65f4..45683ee 100644 --- a/pages/api/cronjob/checkStatus.ts +++ b/pages/api/cronjob/checkStatus.ts @@ -76,16 +76,21 @@ export default async function handler( if (usersList[0].appriseAlert) { const appriseServicesURLs = usersList[0].appriseServices?.join(' '); const message = `🔴 Some repositories on BorgWarehouse need attention !\nList of down repositories :\n ${repoAliasListToSendAlert}`; - if (usersList[0].appriseMode === 'package') { - await exec(`apprise -v -b '${message}' ${appriseServicesURLs}`); - } else if (usersList[0].appriseMode === 'stateless') { - await fetch(`${usersList[0].appriseStatelessURL}/notify`, { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ urls: appriseServicesURLs, body: message }), - }); - } else { - return ApiResponse.validationError(res, 'No Apprise Mode selected or supported.'); + + try { + if (usersList[0].appriseMode === 'package') { + await exec(`apprise -v -b '${message}' ${appriseServicesURLs}`); + } else if (usersList[0].appriseMode === 'stateless') { + await fetch(`${usersList[0].appriseStatelessURL}/notify`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ urls: appriseServicesURLs, body: message }), + }); + } else { + console.warn('No Apprise Mode selected or supported.'); + } + } catch (notifErr) { + console.error('Apprise notification failed:', notifErr); } } }