Code modification of issue 191 of zentao.
This commit is contained in:
+18
-15
@@ -153,7 +153,7 @@ class webhookModel extends model
|
||||
->get();
|
||||
$webhook->params = $this->post->params ? implode(',', $this->post->params) . ',text' : 'text';
|
||||
|
||||
if($webhook->type == 'dingapi')
|
||||
if($webhook->type == 'dinguser')
|
||||
{
|
||||
$webhook->secret = array();
|
||||
$webhook->secret['agentId'] = $webhook->agentId;
|
||||
@@ -167,7 +167,8 @@ class webhookModel extends model
|
||||
|
||||
$webhook->secret = json_encode($webhook->secret);
|
||||
$webhook->url = $this->config->webhook->dingapiUrl;
|
||||
}elseif ($webhook->type == 'wechatApi')
|
||||
}
|
||||
elseif ($webhook->type == 'wechatuser')
|
||||
{
|
||||
$webhook->secret = array();
|
||||
$webhook->secret['agentId'] = $webhook->wechatAgentId;
|
||||
@@ -219,7 +220,7 @@ class webhookModel extends model
|
||||
->get();
|
||||
$webhook->params = $this->post->params ? implode(',', $this->post->params) . ',text' : 'text';
|
||||
|
||||
if($webhook->type == 'dingapi')
|
||||
if($webhook->type == 'dinguser')
|
||||
{
|
||||
$webhook->secret = array();
|
||||
$webhook->secret['agentId'] = $webhook->agentId;
|
||||
@@ -232,7 +233,8 @@ class webhookModel extends model
|
||||
if(dao::isError()) return false;
|
||||
|
||||
$webhook->secret = json_encode($webhook->secret);
|
||||
}elseif ($webhook->type == 'wechatApi')
|
||||
}
|
||||
elseif ($webhook->type == 'wechatuser')
|
||||
{
|
||||
$webhook->secret = array();
|
||||
$webhook->secret['agentId'] = $webhook->wechatAgentId;
|
||||
@@ -310,7 +312,7 @@ class webhookModel extends model
|
||||
|
||||
if($webhook->sendType == 'async')
|
||||
{
|
||||
if($webhook->type == 'dingapi')
|
||||
if($webhook->type == 'dinguser')
|
||||
{
|
||||
$openIdList = $this->getOpenIdList($webhook->id, $actionID);
|
||||
if(empty($openIdList)) continue;
|
||||
@@ -383,15 +385,15 @@ class webhookModel extends model
|
||||
}
|
||||
$action->text = $text;
|
||||
|
||||
if($webhook->type == 'dingding' or $webhook->type == 'dingapi')
|
||||
if($webhook->type == 'dinggroup' or $webhook->type == 'dinguser')
|
||||
{
|
||||
$data = $this->getDingdingData($title, $text, $webhook->type == 'dingapi' ? '' : $mobile);
|
||||
$data = $this->getDingdingData($title, $text, $webhook->type == 'dinguser' ? '' : $mobile);
|
||||
}
|
||||
elseif($webhook->type == 'bearychat')
|
||||
{
|
||||
$data = $this->getBearychatData($text, $mobile, $email, $objectType, $objectID);
|
||||
}
|
||||
elseif($webhook->type == 'weixin' or $webhook->type == 'wechatApi')
|
||||
elseif($webhook->type == 'wechatgroup' or $webhook->type == 'wechatuser')
|
||||
{
|
||||
$data = $this->getWeixinData($title, $text, $mobile);
|
||||
}
|
||||
@@ -559,18 +561,20 @@ class webhookModel extends model
|
||||
{
|
||||
if(!extension_loaded('curl')) die(helper::jsonEncode($this->lang->webhook->error->curl));
|
||||
|
||||
if($webhook->type == 'dingapi' || $webhook->type == 'wechatApi')
|
||||
if($webhook->type == 'dinguser' || $webhook->type == 'wechatuser')
|
||||
{
|
||||
if(is_string($webhook->secret)) $webhook->secret = json_decode($webhook->secret);
|
||||
|
||||
$openIdList = $this->getOpenIdList($webhook->id, $actionID);
|
||||
if(empty($openIdList)) return false;
|
||||
if($webhook->type == 'dingapi'){
|
||||
if($webhook->type == 'dinguser')
|
||||
{
|
||||
$this->app->loadClass('dingapi', true);
|
||||
$dingapi = new dingapi($webhook->secret->appKey, $webhook->secret->appSecret, $webhook->secret->agentId);
|
||||
$result = $dingapi->send($openIdList, $sendData);
|
||||
return json_encode($result);
|
||||
}elseif ($webhook->type == 'wechatApi')
|
||||
}
|
||||
elseif ($webhook->type == 'wechatuser')
|
||||
{
|
||||
$this->app->loadClass('wechatapi', true);
|
||||
$wechatapi = new wechatapi($webhook->secret->appKey, $webhook->secret->appSecret, $webhook->secret->agentId);
|
||||
@@ -580,11 +584,11 @@ class webhookModel extends model
|
||||
}
|
||||
|
||||
$contentType = "Content-Type: {$webhook->contentType};charset=utf-8";
|
||||
if($webhook->type == 'dingding' or $webhook->type == 'weixin') $contentType = "Content-Type: application/json";
|
||||
if($webhook->type == 'dinggroup' or $webhook->type == 'wechatgroup') $contentType = "Content-Type: application/json";
|
||||
$header[] = $contentType;
|
||||
|
||||
$url = $webhook->url;
|
||||
if($webhook->type == 'dingding' and $webhook->secret)
|
||||
if($webhook->type == 'dinggroup' and $webhook->secret)
|
||||
{
|
||||
$timestamp = time() * 1000;
|
||||
$sign = $timestamp . "\n" . $webhook->secret;
|
||||
@@ -640,8 +644,7 @@ class webhookModel extends model
|
||||
|
||||
/**
|
||||
* Save log.
|
||||
*
|
||||
* @param int $webhookID
|
||||
*
|
||||
* @param int $actionID
|
||||
* @param object $webhook
|
||||
* @param string $data
|
||||
|
||||
Reference in New Issue
Block a user