Zentao docking enterprise wechat work message notice.
This commit is contained in:
@@ -161,7 +161,23 @@ class webhookModel extends model
|
||||
|
||||
$webhook->secret = json_encode($webhook->secret);
|
||||
$webhook->url = $this->config->webhook->dingapiUrl;
|
||||
}elseif ($webhook->type == 'weixin')
|
||||
{
|
||||
$webhook->secret = array();
|
||||
$webhook->secret['agentId'] = $webhook->wechatAppId;
|
||||
$webhook->secret['appKey'] = $webhook->wechatCorpId;
|
||||
$webhook->secret['appSecret'] = $webhook->wechatSecret;
|
||||
|
||||
if(empty($webhook->wechatCorpId)) dao::$errors['wechatCorpId'] = sprintf($this->lang->error->notempty, $this->lang->webhook->wechatCorpId);
|
||||
if(empty($webhook->wechatSecret)) dao::$errors['wechatSecret'] = sprintf($this->lang->error->notempty, $this->lang->webhook->wechatCorpSecret);
|
||||
if(empty($webhook->wechatAppId)) dao::$errors['wechatAppId'] = sprintf($this->lang->error->notempty, $this->lang->webhook->wechatAgentId);
|
||||
if(dao::isError()) return false;
|
||||
|
||||
$webhook->secret = json_encode($webhook->secret);
|
||||
$webhook->url = $this->config->webhook->wechatApiUrl;
|
||||
}
|
||||
|
||||
unset($webhook->wechatCorpId, $webhook->wechatSecret, $webhook->wechatAppId);
|
||||
|
||||
$this->dao->insert(TABLE_WEBHOOK)->data($webhook, 'agentId,appKey,appSecret')
|
||||
->batchCheck($this->config->webhook->create->requiredFields, 'notempty')
|
||||
@@ -202,9 +218,24 @@ class webhookModel extends model
|
||||
if(empty($webhook->appSecret)) dao::$errors['appSecret'] = sprintf($this->lang->error->notempty, $this->lang->webhook->dingAppSecret);
|
||||
if(dao::isError()) return false;
|
||||
|
||||
$webhook->secret = json_encode($webhook->secret);
|
||||
}elseif ($webhook->type == 'weixin')
|
||||
{
|
||||
$webhook->secret = array();
|
||||
$webhook->secret['agentId'] = $webhook->wechatCorpId;
|
||||
$webhook->secret['appKey'] = $webhook->wechatSecret;
|
||||
$webhook->secret['appSecret'] = $webhook->wechatAppId;
|
||||
|
||||
if(empty($webhook->wechatCorpId)) dao::$errors['wechatCorpId'] = sprintf($this->lang->error->notempty, $this->lang->webhook->wechatCorpId);
|
||||
if(empty($webhook->wechatSecret)) dao::$errors['wechatSecret'] = sprintf($this->lang->error->notempty, $this->lang->webhook->wechatCorpSecret);
|
||||
if(empty($webhook->wechatAppId)) dao::$errors['wechatAppId'] = sprintf($this->lang->error->notempty, $this->lang->webhook->wechatAgentId);
|
||||
if(dao::isError()) return false;
|
||||
|
||||
$webhook->secret = json_encode($webhook->secret);
|
||||
}
|
||||
|
||||
unset($webhook->wechatCorpId, $webhook->wechatSecret, $webhook->wechatAppId);
|
||||
|
||||
$this->dao->update(TABLE_WEBHOOK)->data($webhook, 'agentId,appKey,appSecret')
|
||||
->batchCheck($this->config->webhook->edit->requiredFields, 'notempty')
|
||||
->autoCheck()
|
||||
@@ -347,7 +378,7 @@ class webhookModel extends model
|
||||
{
|
||||
$data = $this->getBearychatData($text, $mobile, $email, $objectType, $objectID);
|
||||
}
|
||||
elseif($webhook->type == 'weixin')
|
||||
elseif($webhook->type == 'weixin' or $webhook->type == 'wxRobot')
|
||||
{
|
||||
$data = $this->getWeixinData($title, $text, $mobile);
|
||||
}
|
||||
@@ -515,17 +546,24 @@ class webhookModel extends model
|
||||
{
|
||||
if(!extension_loaded('curl')) die(helper::jsonEncode($this->lang->webhook->error->curl));
|
||||
|
||||
if($webhook->type == 'dingapi')
|
||||
if($webhook->type == 'dingapi' || $webhook->type == 'weixin')
|
||||
{
|
||||
if(is_string($webhook->secret)) $webhook->secret = json_decode($webhook->secret);
|
||||
|
||||
$openIdList = $this->getOpenIdList($webhook->id, $actionID);
|
||||
if(empty($openIdList)) return false;
|
||||
|
||||
$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);
|
||||
if($webhook->type == 'dingapi'){
|
||||
$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 == 'weixin')
|
||||
{
|
||||
$this->app->loadClass('wechatapi', true);
|
||||
$wechatapi = new wechatapi($webhook->secret->appKey, $webhook->secret->appSecret, $webhook->secret->agentId);
|
||||
$result = $wechatapi->send($openIdList, $sendData);
|
||||
return json_encode($result);
|
||||
}
|
||||
}
|
||||
|
||||
$contentType = "Content-Type: {$webhook->contentType};charset=utf-8";
|
||||
|
||||
Reference in New Issue
Block a user