Browse Source

bug fix, ignore no notify_url tasks

master
filesite 6 months ago
parent
commit
7e61600cae
  1. 10
      heroUnion.mjs
  2. 5
      test/common.test.mjs

10
heroUnion.mjs

@ -318,9 +318,6 @@ class HeroUnion { @@ -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 { @@ -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);
}

5
test/common.test.mjs

@ -165,4 +165,9 @@ test('Common function isUrlOk test', async (t) => { @@ -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);
});
Loading…
Cancel
Save