* Fix bug.

This commit is contained in:
liugang
2017-10-24 18:10:07 +08:00
parent 37bb58a23e
commit 785c49ca54
2 changed files with 9 additions and 10 deletions
+6 -5
View File
@@ -132,16 +132,17 @@ class webhook extends control
$snoopy = $this->app->loadClass('snoopy');
foreach($dataList as $data)
{
$webhook = zget($webhooks, $data->webhook, '');
$webhook = zget($webhooks, $data->webhook, '');
$httpCode = 0;
if($webhook)
{
$snoopy->_submit_type = zget($this->config->webhook->contentTypes, $webhook->contentType, 'application/json');
$snoopy->submit($webhook->url, $data->data);
$contentType = zget($this->config->webhook->contentTypes, $webhook->contentType, 'application/json');
$httpCode = $this->webhook->fetchHook($contentType, $webhook->url, $data->data);
$this->saveLog($data->webhook, $data->action, $webhook->url, $snoopy->_submit_type, $postData, $snoopy->status, $snoopy->error);
$this->saveLog($data->webhook, $data->action, $webhook->url, $contentType, $data->data, $httpCode);
}
if($snoopy->status == 200) $this->dao->update(TABLE_WEBHOOKDATA)->set('status')->eq('sended')->where('id')->eq($data->id)->exec();
if($httpCode == 200) $this->dao->update(TABLE_WEBHOOKDATA)->set('status')->eq('sended')->where('id')->eq($data->id)->exec();
}
$this->dao->delete()->from(TABLE_WEBHOOKDATA)->where('status')->eq('sended')->exec();
+3 -5
View File
@@ -198,9 +198,9 @@ class webhookModel extends model
}
$contentType = zget($this->config->webhook->contentTypes, $webhook->contentType, 'application/json');
$result = $this->fetchHook($contentType, $webhook->url, $postData);
$httpCode = $this->fetchHook($contentType, $webhook->url, $postData);
$this->saveLog($id, $actionID, $webhook->url, $contentType, $postData, $result);
$this->saveLog($id, $actionID, $webhook->url, $contentType, $postData, $httpCode);
}
return !dao::isError();
}
@@ -330,11 +330,10 @@ class webhookModel extends model
* @param string $contentType
* @param string $data
* @param int $status
* @param string $error
* @access public
* @return bool
*/
public function saveLog($webhookID, $actionID, $url, $contentType, $data, $status, $error = '')
public function saveLog($webhookID, $actionID, $url, $contentType, $data, $status)
{
$log = new stdclass();
$log->objectType = 'webhook';
@@ -345,7 +344,6 @@ class webhookModel extends model
$log->contentType = $contentType;
$log->data = $data;
$log->status = $status;
$log->error = $error;
$this->dao->insert(TABLE_LOG)->data($log)->exec();
return !dao::isError();