From 7e61600cae2aa4866a4b44e9c188816a66b39131 Mon Sep 17 00:00:00 2001 From: filesite Date: Thu, 6 Jun 2024 06:25:05 +0800 Subject: [PATCH] bug fix, ignore no notify_url tasks --- heroUnion.mjs | 10 ++++++---- test/common.test.mjs | 5 +++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/heroUnion.mjs b/heroUnion.mjs index 3a35873..6cc8ae7 100644 --- a/heroUnion.mjs +++ b/heroUnion.mjs @@ -318,9 +318,6 @@ class HeroUnion { async handleTaskDone(task) { let notified = false; let notify_url = task.notify_url; - if (!notify_url || common.isUrlOk(notify_url) == false) { - return false; - } try { common.log('[%s] Try to notify task %s via %s', task.notify_time, task.id, notify_url); @@ -540,13 +537,18 @@ class HeroUnion { } //定期尝试给已完成状态的任务notify_url发送通知回调 + //bug fix:忽略没有notify_url的任务 autoNotifyTasks() { const _self = this; const frequence = typeof(this.config.autoNotifyTaskFrequence) != 'undefined' && this.config.autoNotifyTaskFrequence ? this.config.autoNotifyTaskFrequence : 2; //2 分钟检查一次 const cronjob = cron.schedule(`*/${frequence} * * * *`, () => { - let task = _self.tasks.find((item) => item.status == 'done' && item.notified == false && item.notify_time < _self.notify_max_try); + let task = _self.tasks.find((item) => common.isUrlOk(item.notify_url) && + item.status == 'done' && + item.notified == false && + item.notify_time < _self.notify_max_try + ); if (task) { _self.handleTaskDone(task); } diff --git a/test/common.test.mjs b/test/common.test.mjs index 1a4539f..b1ae255 100644 --- a/test/common.test.mjs +++ b/test/common.test.mjs @@ -165,4 +165,9 @@ test('Common function isUrlOk test', async (t) => { url = 'https://www.bil-ibili.com/video/BV1AM4_1137LB/'; urlOk = common.isUrlOk(url); assert.equal(urlOk, true); + + //case 6 + url = 'https://tajian.tv/1000/frontapi/hunotify/'; + urlOk = common.isUrlOk(url); + assert.equal(urlOk, true); }); \ No newline at end of file