From 6e576929b7c814c70c58f59161e64a274b4be30d Mon Sep 17 00:00:00 2001 From: z Date: Wed, 2 Sep 2020 12:18:47 +0800 Subject: [PATCH] * adjust for async send webhook. --- module/webhook/control.php | 2 ++ module/webhook/model.php | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/module/webhook/control.php b/module/webhook/control.php index 7ad188d636..c12e056c2f 100644 --- a/module/webhook/control.php +++ b/module/webhook/control.php @@ -317,6 +317,8 @@ class webhook extends control return true; } + $this->webhook->setSentStatus(array_keys($dataList), 'senting'); + $now = helper::now(); $diff = 0; foreach($dataList as $data) diff --git a/module/webhook/model.php b/module/webhook/model.php index 24871d41cf..2bff701135 100644 --- a/module/webhook/model.php +++ b/module/webhook/model.php @@ -118,7 +118,9 @@ class webhookModel extends model */ public function getDataList() { - return $this->dao->select('*')->from(TABLE_NOTIFY)->where('status')->eq('wait')->andWhere('objectType')->eq('webhook')->orderBy('id')->fetchAll('id'); + $dataList = $this->dao->select('*')->from(TABLE_NOTIFY)->where('status')->eq('wait')->andWhere('objectType')->eq('webhook')->orderBy('id')->fetchAll('id'); + $dataList += $this->dao->select('*')->from(TABLE_NOTIFY)->where('status')->eq('senting')->andWhere('sendTime')->ge(date('Y-m-d H:i:s', time() - 3 * 3600))->andWhere('objectType')->eq('webhook')->orderBy('id')->fetchAll('id'); + return $dataList; } /** @@ -675,4 +677,18 @@ class webhookModel extends model $this->dao->insert(TABLE_LOG)->data($log)->exec(); return !dao::isError(); } + + /** + * Set sent status. + * + * @param array $idList + * @param string $status + * @access public + * @return void + */ + public function setSentStatus($idList, $status) + { + $now = helper::now(); + $this->dao->update(TABLE_NOTIFY)->set('status')->eq($status)->set('sendTime')->eq($now)->where('id')->id($idList)->exec(); + } }