From 351337f654ec38ea93b2aad031b05c22311f9c76 Mon Sep 17 00:00:00 2001 From: bsourisse Date: Mon, 13 Mar 2023 23:55:31 +0100 Subject: [PATCH] feat: add a control on button to send apprise test --- pages/api/account/sendTestApprise.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pages/api/account/sendTestApprise.js b/pages/api/account/sendTestApprise.js index 9ffd44f..b211bd7 100644 --- a/pages/api/account/sendTestApprise.js +++ b/pages/api/account/sendTestApprise.js @@ -45,7 +45,19 @@ export default async function handler(req, res) { return; } - ////3 : Send the notification to services + //3 : if there is no service URLs, throw error + if ( + !usersList[userIndex].appriseServices || + usersList[userIndex].appriseServices.length === 0 + ) { + res.status(422).json({ + message: + 'You must provide at least one Apprise URL to send a test.', + }); + return; + } + + ////4 : Send the notification to services //Build the URLs service list as a single string let appriseServicesURLs = ''; for (let service of usersList[userIndex].appriseServices) {