From 91c2fdc7016b7216136195d18c1fc62cc997b173 Mon Sep 17 00:00:00 2001 From: Tzahi12345 Date: Wed, 29 Nov 2023 21:04:27 -0500 Subject: [PATCH] Failed telegram request now sends a response to telegram --- backend/app.js | 2 ++ backend/notifications.js | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/app.js b/backend/app.js index 114f7ae..4784f2a 100644 --- a/backend/app.js +++ b/backend/app.js @@ -30,6 +30,7 @@ const twitch_api = require('./twitch'); const youtubedl_api = require('./youtube-dl'); const archive_api = require('./archive'); const files_api = require('./files'); +const notifications_api = require('./notifications'); var app = express(); @@ -2110,6 +2111,7 @@ app.post('/api/telegramRequest', async (req, res) => { res.sendStatus(200); } else { logger.error('Invalid Telegram request received! Make sure you only send a valid URL.'); + notifications_api.sendTelegramNotification({title: 'Invalid Telegram Request', body: 'Make sure you only send a valid URL.', url: text}); res.sendStatus(400); } }); diff --git a/backend/notifications.js b/backend/notifications.js index a2f4810..af5be13 100644 --- a/backend/notifications.js +++ b/backend/notifications.js @@ -59,7 +59,7 @@ exports.sendNotification = async (notification) => { sendGotifyNotification(data); } if (config_api.getConfigItem('ytdl_use_telegram_API') && config_api.getConfigItem('ytdl_telegram_bot_token') && config_api.getConfigItem('ytdl_telegram_chat_id')) { - sendTelegramNotification(data); + exports.sendTelegramNotification(data); } if (config_api.getConfigItem('ytdl_webhook_url')) { sendGenericNotification(data); @@ -176,7 +176,7 @@ async function setupTelegramBot() { telegram_bot.setWebHook(webhook_url); } -async function sendTelegramNotification({body, title, type, url, thumbnail}) { +exports.sendTelegramNotification = async ({body, title, type, url, thumbnail}) => { if (!telegram_bot){ logger.error('Telegram bot not found!'); return;