* finish task #6543.
This commit is contained in:
@@ -3,11 +3,11 @@ $(function()
|
|||||||
$('#type').change(function()
|
$('#type').change(function()
|
||||||
{
|
{
|
||||||
var type = $(this).val();
|
var type = $(this).val();
|
||||||
$('#sendTypeTR').toggle(type != 'dingding');
|
$('#sendTypeTR').toggle(type != 'dingding' && type != 'dingapi');
|
||||||
$('#secretTR').toggle(type == 'dingding');
|
$('#secretTR').toggle(type == 'dingding');
|
||||||
$('#urlTR').toggle(type != 'dingapi');
|
$('#urlTR').toggle(type != 'dingapi');
|
||||||
$('.dingapiTR').toggle(type == 'dingapi');
|
$('.dingapiTR').toggle(type == 'dingapi');
|
||||||
$('#paramsTR').toggle(type != 'bearychat' && type != 'dingding' && type != 'dingapi');
|
$('#paramsTR').toggle(type != 'bearychat' && type != 'dingding' && type != 'dingapi' && type != 'weixin');
|
||||||
$('#urlNote').html(urlNote[type]);
|
$('#urlNote').html(urlNote[type]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ $lang->webhook->result = '结果';
|
|||||||
$lang->webhook->typeList[''] = '';
|
$lang->webhook->typeList[''] = '';
|
||||||
$lang->webhook->typeList['dingding'] = '钉钉群通知机器人';
|
$lang->webhook->typeList['dingding'] = '钉钉群通知机器人';
|
||||||
$lang->webhook->typeList['dingapi'] = '钉钉工作消息通知';
|
$lang->webhook->typeList['dingapi'] = '钉钉工作消息通知';
|
||||||
|
$lang->webhook->typeList['weixin'] = '企业微信';
|
||||||
$lang->webhook->typeList['default'] = '其他';
|
$lang->webhook->typeList['default'] = '其他';
|
||||||
|
|
||||||
$lang->webhook->sendTypeList['sync'] = '同步';
|
$lang->webhook->sendTypeList['sync'] = '同步';
|
||||||
|
|||||||
@@ -257,6 +257,7 @@ class webhookModel extends model
|
|||||||
|
|
||||||
if($webhook->sendType == 'async')
|
if($webhook->sendType == 'async')
|
||||||
{
|
{
|
||||||
|
if($webhook->type == 'dingapi' and empty($this->getUseridList($webhook->id, $actionID))) continue;
|
||||||
$this->saveData($id, $actionID, $postData);
|
$this->saveData($id, $actionID, $postData);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -332,6 +333,10 @@ class webhookModel extends model
|
|||||||
{
|
{
|
||||||
$data = $this->getBearychatData($text, $mobile, $email, $objectType, $objectID);
|
$data = $this->getBearychatData($text, $mobile, $email, $objectType, $objectID);
|
||||||
}
|
}
|
||||||
|
elseif($webhook->type == 'weixin')
|
||||||
|
{
|
||||||
|
$data = $this->getWeixinData($title, $text, $mobile);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$data = new stdclass();
|
$data = new stdclass();
|
||||||
@@ -434,6 +439,29 @@ class webhookModel extends model
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get weixin data.
|
||||||
|
*
|
||||||
|
* @param string $title
|
||||||
|
* @param string $text
|
||||||
|
* @param string $mobile
|
||||||
|
* @access public
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
public function getWeixinData($title, $text, $mobile)
|
||||||
|
{
|
||||||
|
$data = new stdclass();
|
||||||
|
$data->msgtype = 'markdown';
|
||||||
|
|
||||||
|
$markdown = new stdclass();
|
||||||
|
$markdown->content = $text;
|
||||||
|
|
||||||
|
if($mobile) $markdown->mentioned_mobile_list = array($mobile);
|
||||||
|
|
||||||
|
$data->markdown = $markdown;
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get userid list.
|
* Get userid list.
|
||||||
@@ -442,7 +470,7 @@ class webhookModel extends model
|
|||||||
* @access public
|
* @access public
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getUseridList($actionID)
|
public function getUseridList($webhookID, $actionID)
|
||||||
{
|
{
|
||||||
if(empty($actionID)) return false;
|
if(empty($actionID)) return false;
|
||||||
|
|
||||||
@@ -455,7 +483,7 @@ class webhookModel extends model
|
|||||||
if(!empty($object->mailto)) $toList .= ',' . $object->mailto;
|
if(!empty($object->mailto)) $toList .= ',' . $object->mailto;
|
||||||
if(empty($toList)) return false;
|
if(empty($toList)) return false;
|
||||||
|
|
||||||
$useridList = $this->getBindUsers($webhook->id, $toList);
|
$useridList = $this->getBindUsers($webhookID, $toList);
|
||||||
$useridList = join(',', $useridList);
|
$useridList = join(',', $useridList);
|
||||||
return $useridList;
|
return $useridList;
|
||||||
}
|
}
|
||||||
@@ -477,16 +505,17 @@ class webhookModel extends model
|
|||||||
{
|
{
|
||||||
$webhook->secret = json_decode($webhook->secret);
|
$webhook->secret = json_decode($webhook->secret);
|
||||||
|
|
||||||
$useridList = $this->getUseridList($actionID);
|
$useridList = $this->getUseridList($webhook->id, $actionID);
|
||||||
if(empty($useridList)) return false;
|
if(empty($useridList)) return false;
|
||||||
|
|
||||||
$this->app->loadClass('dingapi', true);
|
$this->app->loadClass('dingapi', true);
|
||||||
$dingapi = new dingapi($webhook->secret->appKey, $webhook->secret->appSecret, $webhook->secret->agentId);
|
$dingapi = new dingapi($webhook->secret->appKey, $webhook->secret->appSecret, $webhook->secret->agentId);
|
||||||
return $dingapi->send($useridList, $sendData);
|
$result = $dingapi->send($useridList, $sendData);
|
||||||
|
return json_encode($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
$contentType = "Content-Type: {$webhook->contentType};charset=utf-8";
|
$contentType = "Content-Type: {$webhook->contentType};charset=utf-8";
|
||||||
if($webhook->type == 'dingding') $contentType = "Content-Type: application/json";
|
if($webhook->type == 'dingding' or $webhook->type == 'weixin') $contentType = "Content-Type: application/json";
|
||||||
$header[] = $contentType;
|
$header[] = $contentType;
|
||||||
|
|
||||||
$url = $webhook->url;
|
$url = $webhook->url;
|
||||||
|
|||||||
@@ -51,6 +51,11 @@
|
|||||||
<th><?php echo $lang->webhook->dingAppSecret;?></th>
|
<th><?php echo $lang->webhook->dingAppSecret;?></th>
|
||||||
<td><?php echo html::input('appSecret', '', "class='form-control'");?></td>
|
<td><?php echo html::input('appSecret', '', "class='form-control'");?></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><?php echo $lang->webhook->domain;?></th>
|
||||||
|
<td><?php echo html::input('domain', common::getSysURL(), "class='form-control'");?></td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
<tr id='sendTypeTR'>
|
<tr id='sendTypeTR'>
|
||||||
<th><?php echo $lang->webhook->sendType;?></th>
|
<th><?php echo $lang->webhook->sendType;?></th>
|
||||||
<td><?php echo html::select('sendType', $lang->webhook->sendTypeList, '', "class='form-control'");?></td>
|
<td><?php echo html::select('sendType', $lang->webhook->sendTypeList, '', "class='form-control'");?></td>
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
<td><?php echo html::input('name', $webhook->name, "class='form-control'");?></td>
|
<td><?php echo html::input('name', $webhook->name, "class='form-control'");?></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr id='urlTR' class='hidden'>
|
<tr id='urlTR' class='<?php echo $webhook->type == 'dingapi' ? 'hidden' : '';?>'>
|
||||||
<th><?php echo $lang->webhook->url;?></th>
|
<th><?php echo $lang->webhook->url;?></th>
|
||||||
<td><?php echo html::input('url', $webhook->url, "class='form-control'");?></td>
|
<td><?php echo html::input('url', $webhook->url, "class='form-control'");?></td>
|
||||||
<td><?php echo zget($lang->webhook->note->typeList, $webhook->type, '');?></td>
|
<td><?php echo zget($lang->webhook->note->typeList, $webhook->type, '');?></td>
|
||||||
@@ -60,7 +60,7 @@
|
|||||||
<td><?php echo html::input('domain', $webhook->domain, "class='form-control'");?></td>
|
<td><?php echo html::input('domain', $webhook->domain, "class='form-control'");?></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php if($webhook->type != 'dingding'):?>
|
<?php if($webhook->type != 'dingding' and $webhook->type != 'dingapi'):?>
|
||||||
<tr>
|
<tr>
|
||||||
<th><?php echo $lang->webhook->sendType;?></th>
|
<th><?php echo $lang->webhook->sendType;?></th>
|
||||||
<td><?php echo html::select('sendType', $lang->webhook->sendTypeList, $webhook->sendType, "class='form-control'");?></td>
|
<td><?php echo html::select('sendType', $lang->webhook->sendTypeList, $webhook->sendType, "class='form-control'");?></td>
|
||||||
@@ -77,7 +77,7 @@
|
|||||||
<td><?php echo html::select('projects[]', $projects, $webhook->projects, "class='form-control chosen' multiple");?></td>
|
<td><?php echo html::select('projects[]', $projects, $webhook->projects, "class='form-control chosen' multiple");?></td>
|
||||||
<td><?php echo $lang->webhook->note->project;?></td>
|
<td><?php echo $lang->webhook->note->project;?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php if(strpos(',bearychat,dingding,dingapi,', ",$webhook->type,") === false):?>
|
<?php if(strpos(',bearychat,dingding,dingapi,weixin,', ",$webhook->type,") === false):?>
|
||||||
<tr id='paramsTR'>
|
<tr id='paramsTR'>
|
||||||
<th>
|
<th>
|
||||||
<div class='checkbox-primary'>
|
<div class='checkbox-primary'>
|
||||||
|
|||||||
Reference in New Issue
Block a user