|
|
|
@ -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); |
|
|
|
|
} |
|
|
|
|