diff --git a/module/webhook/config.php b/module/webhook/config.php index 3a014363fd..99c6912955 100644 --- a/module/webhook/config.php +++ b/module/webhook/config.php @@ -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'); diff --git a/module/webhook/css/create.zh-cn.css b/module/webhook/css/create.zh-cn.css index 6e60376bc6..b3e7551ab2 100644 --- a/module/webhook/css/create.zh-cn.css +++ b/module/webhook/css/create.zh-cn.css @@ -1 +1 @@ -.thWidth{width:90px !important;} +.thWidth{width:110px !important;} diff --git a/module/webhook/css/create.zh-tw.css b/module/webhook/css/create.zh-tw.css index 6e60376bc6..b3e7551ab2 100644 --- a/module/webhook/css/create.zh-tw.css +++ b/module/webhook/css/create.zh-tw.css @@ -1 +1 @@ -.thWidth{width:90px !important;} +.thWidth{width:110px !important;} diff --git a/module/webhook/css/edit.zh-cn.css b/module/webhook/css/edit.zh-cn.css index 6e60376bc6..b3e7551ab2 100644 --- a/module/webhook/css/edit.zh-cn.css +++ b/module/webhook/css/edit.zh-cn.css @@ -1 +1 @@ -.thWidth{width:90px !important;} +.thWidth{width:110px !important;} diff --git a/module/webhook/css/edit.zh-tw.css b/module/webhook/css/edit.zh-tw.css index 6e60376bc6..b3e7551ab2 100644 --- a/module/webhook/css/edit.zh-tw.css +++ b/module/webhook/css/edit.zh-tw.css @@ -1 +1 @@ -.thWidth{width:90px !important;} +.thWidth{width:110px !important;} diff --git a/module/webhook/js/create.js b/module/webhook/js/create.js index 74840304da..bd1ccf4900 100644 --- a/module/webhook/js/create.js +++ b/module/webhook/js/create.js @@ -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]); }); diff --git a/module/webhook/lang/zh-cn.php b/module/webhook/lang/zh-cn.php index dd3b2121b5..8ccc9a71c1 100644 --- a/module/webhook/lang/zh-cn.php +++ b/module/webhook/lang/zh-cn.php @@ -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}"; diff --git a/module/webhook/model.php b/module/webhook/model.php index 70581adc13..f2bc8b9942 100644 --- a/module/webhook/model.php +++ b/module/webhook/model.php @@ -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) diff --git a/module/webhook/view/create.html.php b/module/webhook/view/create.html.php index ddad766f7e..34836bea7f 100644 --- a/module/webhook/view/create.html.php +++ b/module/webhook/view/create.html.php @@ -30,7 +30,7 @@