* change for dingding.
This commit is contained in:
1
db/update11.6.4.sql
Normal file
1
db/update11.6.4.sql
Normal file
@@ -0,0 +1 @@
|
||||
ALTER TABLE `zt_webhook` ADD `secret` varchar(255) COLLATE 'utf8_general_ci' NOT NULL AFTER `domain`;
|
||||
@@ -4,6 +4,7 @@ $(function()
|
||||
{
|
||||
var type = $(this).val();
|
||||
$('#sendTypeTR').toggle(type != 'dingding');
|
||||
$('#secretTR').toggle(type == 'dingding');
|
||||
$('#paramsTR').toggle(type != 'bearychat' && type != 'dingding');
|
||||
$('#urlNote').html(urlNote[type]);
|
||||
});
|
||||
@@ -33,5 +34,6 @@ $(function()
|
||||
});
|
||||
|
||||
$('#name').focus();
|
||||
$('#type').change();
|
||||
$('#paramstext').attr('disabled', 'disabled');
|
||||
});
|
||||
|
||||
@@ -19,6 +19,7 @@ $lang->webhook->url = 'Hook地址';
|
||||
$lang->webhook->domain = '禅道域名';
|
||||
$lang->webhook->contentType = '内容类型';
|
||||
$lang->webhook->sendType = '发送方式';
|
||||
$lang->webhook->secret = '密钥';
|
||||
$lang->webhook->product = "关联{$lang->productCommon}";
|
||||
$lang->webhook->project = "关联{$lang->projectCommon}";
|
||||
$lang->webhook->params = '参数';
|
||||
|
||||
@@ -379,10 +379,21 @@ class webhookModel extends model
|
||||
{
|
||||
if(!extension_loaded('curl')) die(helper::jsonEncode($this->lang->webhook->error->curl));
|
||||
|
||||
$header[] = "Content-Type: {$webhook->contentType};charset=utf-8";
|
||||
$contentType = "Content-Type: {$webhook->contentType};charset=utf-8";
|
||||
if($webhook->type == 'dingding') $contentType = "Content-Type: application/json";
|
||||
$header[] = $contentType;
|
||||
|
||||
$url = $webhook->url;
|
||||
if($webhook->type == 'dingding' and $webhook->secret)
|
||||
{
|
||||
$timestamp = time() * 1000;
|
||||
$sign = $timestamp . "\n" . $webhook->secret;
|
||||
$sign = urlencode(base64_encode(hash_hmac('sha256', $sign, $webhook->secret, true)));
|
||||
$url .= "×tamp={$timestamp}&sign={$sign}";
|
||||
}
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $webhook->url);
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
||||
|
||||
@@ -35,6 +35,10 @@
|
||||
<td><?php echo html::input('url', '', "class='form-control'");?></td>
|
||||
<td id='urlNote'><?php echo $lang->webhook->note->typeList['default'];?></td>
|
||||
</tr>
|
||||
<tr id='secretTR'>
|
||||
<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>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<table class='table table-form'>
|
||||
<tr>
|
||||
<th class='thWidth'><?php echo $lang->webhook->type;?></th>
|
||||
<td><?php echo html::select('type', $lang->webhook->typeList, $webhook->type, "class='form-control'");?></td>
|
||||
<td><?php echo zget($lang->webhook->typeList, $webhook->type);?></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -34,6 +34,12 @@
|
||||
<td><?php echo html::input('url', $webhook->url, "class='form-control'");?></td>
|
||||
<td><?php echo zget($lang->webhook->note->typeList, $webhook->type);?></td>
|
||||
</tr>
|
||||
<?php if($webhook->type == 'dingding'):?>
|
||||
<tr id='secretTR'>
|
||||
<th><?php echo $lang->webhook->secret;?></th>
|
||||
<td><?php echo html::input('secret', $webhook->secret, "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>
|
||||
|
||||
Reference in New Issue
Block a user