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 {
async handleTaskDone(task) { async handleTaskDone(task) {
let notified = false; let notified = false;
let notify_url = task.notify_url; let notify_url = task.notify_url;
if (!notify_url || common.isUrlOk(notify_url) == false) {
return false;
}
try { try {
common.log('[%s] Try to notify task %s via %s', task.notify_time, task.id, notify_url); 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发送通知回调 //定期尝试给已完成状态的任务notify_url发送通知回调
//bug fix:忽略没有notify_url的任务
autoNotifyTasks() { autoNotifyTasks() {
const _self = this; const _self = this;
const frequence = typeof(this.config.autoNotifyTaskFrequence) != 'undefined' const frequence = typeof(this.config.autoNotifyTaskFrequence) != 'undefined'
&& this.config.autoNotifyTaskFrequence ? this.config.autoNotifyTaskFrequence : 2; //2 分钟检查一次 && this.config.autoNotifyTaskFrequence ? this.config.autoNotifyTaskFrequence : 2; //2 分钟检查一次
const cronjob = cron.schedule(`*/${frequence} * * * *`, () => { 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) { if (task) {
_self.handleTaskDone(task); _self.handleTaskDone(task);
} }

5
test/common.test.mjs

@ -165,4 +165,9 @@ test('Common function isUrlOk test', async (t) => {
url = 'https://www.bil-ibili.com/video/BV1AM4_1137LB/'; url = 'https://www.bil-ibili.com/video/BV1AM4_1137LB/';
urlOk = common.isUrlOk(url); urlOk = common.isUrlOk(url);
assert.equal(urlOk, true); assert.equal(urlOk, true);
//case 6
url = 'https://tajian.tv/1000/frontapi/hunotify/';
urlOk = common.isUrlOk(url);
assert.equal(urlOk, true);
}); });
Loading…
Cancel
Save