* finish task #6536.

This commit is contained in:
wangyidong
2019-11-15 09:04:48 +08:00
parent 64b8d04f77
commit eb1267ebe7
10 changed files with 55 additions and 16 deletions
+2
View File
@@ -5,6 +5,8 @@ $config->webhook->create->requiredFields = 'name, url';
$config->webhook->edit = new stdclass();
$config->webhook->edit->requiredFields = 'name, url';
$config->webhook->dingapiUrl = 'https://oapi.dingtalk.com/';
/* Unset entry to hide actions. */
$config->webhook->objectTypes = array();
$config->webhook->objectTypes['product'] = array('opened', 'edited', 'closed', 'undeleted');
+1 -1
View File
@@ -1 +1 @@
.thWidth{width:90px !important;}
.thWidth{width:110px !important;}
+1 -1
View File
@@ -1 +1 @@
.thWidth{width:90px !important;}
.thWidth{width:110px !important;}
+1 -1
View File
@@ -1 +1 @@
.thWidth{width:90px !important;}
.thWidth{width:110px !important;}
+1 -1
View File
@@ -1 +1 @@
.thWidth{width:90px !important;}
.thWidth{width:110px !important;}
+3 -1
View File
@@ -5,7 +5,9 @@ $(function()
var type = $(this).val();
$('#sendTypeTR').toggle(type != 'dingding');
$('#secretTR').toggle(type == 'dingding');
$('#paramsTR').toggle(type != 'bearychat' && type != 'dingding');
$('#urlTR').toggle(type != 'dingapi');
$('.dingapiTR').toggle(type == 'dingapi');
$('#paramsTR').toggle(type != 'bearychat' && type != 'dingding' && type != 'dingapi');
$('#urlNote').html(urlNote[type]);
});
+5 -1
View File
@@ -34,12 +34,16 @@ $lang->webhook->data = '数据';
$lang->webhook->result = '结果';
$lang->webhook->typeList[''] = '';
$lang->webhook->typeList['dingding'] = '钉钉';
$lang->webhook->typeList['dingding'] = '钉钉群通知机器人';
$lang->webhook->typeList['dingapi'] = '钉钉工作消息通知';
$lang->webhook->typeList['default'] = '其他';
$lang->webhook->sendTypeList['sync'] = '同步';
$lang->webhook->sendTypeList['async'] = '异步';
$lang->webhook->dingAppKey = '钉钉AppKey';
$lang->webhook->dingAppSecret = '钉钉AppSecret';
$lang->webhook->paramsList['objectType'] = '对象类型';
$lang->webhook->paramsList['objectID'] = '对象ID';
$lang->webhook->paramsList['product'] = "所属{$lang->productCommon}";
+19 -2
View File
@@ -130,8 +130,17 @@ class webhookModel extends model
->remove('allParams, allActions')
->get();
$webhook->params = $this->post->params ? implode(',', $this->post->params) . ',text' : 'text';
if($webhook->type == 'dingapi')
{
$webhook->secret = array();
$webhook->secret['appKey'] = $webhook->appKey;
$webhook->secret['appSecret'] = $webhook->appSecret;
$webhook->secret = json_encode($webhook->secret);
$webhook->url = $this->config->webhook->dingapiUrl;
}
$this->dao->insert(TABLE_WEBHOOK)->data($webhook)
$this->dao->insert(TABLE_WEBHOOK)->data($webhook, 'appKey,appSecret')
->batchCheck($this->config->webhook->create->requiredFields, 'notempty')
->autoCheck()
->exec();
@@ -158,8 +167,16 @@ class webhookModel extends model
->remove('allParams, allActions')
->get();
$webhook->params = $this->post->params ? implode(',', $this->post->params) . ',text' : 'text';
if($webhook->type == 'dingapi')
{
$webhook->secret = array();
$webhook->secret['appKey'] = $webhook->appKey;
$webhook->secret['appSecret'] = $webhook->appSecret;
$this->dao->update(TABLE_WEBHOOK)->data($webhook)
$webhook->secret = json_encode($webhook->secret);
}
$this->dao->update(TABLE_WEBHOOK)->data($webhook, 'appKey,appSecret')
->batchCheck($this->config->webhook->edit->requiredFields, 'notempty')
->autoCheck()
->where('id')->eq($id)
+8 -5
View File
@@ -30,7 +30,7 @@
<td><?php echo html::input('name', '', "class='form-control'");?></td>
<td></td>
</tr>
<tr>
<tr id='urlTR'>
<th><?php echo $lang->webhook->url;?></th>
<td><?php echo html::input('url', '', "class='form-control'");?></td>
<td id='urlNote'><?php echo $lang->webhook->note->typeList['default'];?></td>
@@ -39,10 +39,13 @@
<th><?php echo $lang->webhook->secret;?></th>
<td><?php echo html::input('secret', '', "class='form-control'");?></td>
</tr>
<tr>
<th><?php echo $lang->webhook->domain;?></th>
<td><?php echo html::input('domain', common::getSysURL(), "class='form-control'");?></td>
<td></td>
<tr class='dingapiTR'>
<th><?php echo $lang->webhook->dingAppKey;?></th>
<td><?php echo html::input('appKey', '', "class='form-control'");?></td>
</tr>
<tr class='dingapiTR'>
<th><?php echo $lang->webhook->dingAppSecret;?></th>
<td><?php echo html::input('appSecret', '', "class='form-control'");?></td>
</tr>
<tr id='sendTypeTR'>
<th><?php echo $lang->webhook->sendType;?></th>
+14 -3
View File
@@ -29,10 +29,10 @@
<td><?php echo html::input('name', $webhook->name, "class='form-control'");?></td>
<td></td>
</tr>
<tr>
<tr id='urlTR' class='hidden'>
<th><?php echo $lang->webhook->url;?></th>
<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>
</tr>
<?php if($webhook->type == 'dingding'):?>
<tr id='secretTR'>
@@ -40,6 +40,17 @@
<td><?php echo html::input('secret', $webhook->secret, "class='form-control'");?></td>
</tr>
<?php endif;?>
<?php if($webhook->type == 'dingapi'):?>
<?php $secret = json_decode($webhook->secret);?>
<tr class='dingapiTR'>
<th><?php echo $lang->webhook->dingAppKey;?></th>
<td><?php echo html::input('appKey', $secret->appKey, "class='form-control'");?></td>
</tr>
<tr class='dingapiTR'>
<th><?php echo $lang->webhook->dingAppSecret;?></th>
<td><?php echo html::input('appSecret', $secret->appSecret, "class='form-control'");?></td>
</tr>
<?php endif;?>
<tr>
<th><?php echo $lang->webhook->domain;?></th>
<td><?php echo html::input('domain', $webhook->domain, "class='form-control'");?></td>
@@ -62,7 +73,7 @@
<td><?php echo html::select('projects[]', $projects, $webhook->projects, "class='form-control chosen' multiple");?></td>
<td><?php echo $lang->webhook->note->project;?></td>
</tr>
<?php if(strpos(',bearychat,dingding,', ",$webhook->type,") === false):?>
<?php if(strpos(',bearychat,dingding,dingapi,', ",$webhook->type,") === false):?>
<tr id='paramsTR'>
<th>
<div class='checkbox-primary'>