* Add @xxx function when post message to dingding.
This commit is contained in:
+38
-10
@@ -258,7 +258,7 @@ class webhookModel extends model
|
||||
}
|
||||
|
||||
static $users = array();
|
||||
if(empty($users)) $users = $this->loadModel('user')->getPairs('noletter');
|
||||
if(empty($users)) $users = $this->loadModel('user')->getList();
|
||||
|
||||
$object = $this->dao->select('*')->from($this->config->objectTables[$objectType])->where('id')->eq($objectID)->fetch();
|
||||
$field = $this->config->action->objectNameFields[$objectType];
|
||||
@@ -269,17 +269,45 @@ class webhookModel extends model
|
||||
$data = new stdclass();
|
||||
if($webhook->type == 'dingding')
|
||||
{
|
||||
$title = $this->app->user->realname . $this->lang->action->label->$actionType . $this->lang->action->objectTypes[$objectType];
|
||||
if($actionType == 'assigned') $title .= ' ' . $this->lang->webhook->assigned . ' ' . zget($users, $object->assignedTo);
|
||||
$title = $this->app->user->realname . $this->lang->action->label->$actionType . $this->lang->action->objectTypes[$objectType];
|
||||
$mobile = '';
|
||||
if($actionType == 'assigned')
|
||||
{
|
||||
$assignedTo = $object->assignedTo;
|
||||
foreach($users as $user)
|
||||
{
|
||||
if($user->account == $object->assignedTo)
|
||||
{
|
||||
$assignedTo = $user->realname;
|
||||
$mobile = $user->mobile;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if($mobile) $title .= ' ' . "[#{$objectID}::{$title}](" . $host . $viewLink . ")";
|
||||
$title .= ' ' . $this->lang->webhook->assigned . ' ' . $assignedTo;
|
||||
}
|
||||
|
||||
$link = new stdclass();
|
||||
$link->text = "[#{$objectID}::{$text}]";
|
||||
$link->title = $title;
|
||||
$link->picUrl = '';
|
||||
$link->messageUrl = $host . $viewLink;
|
||||
if($mobile)
|
||||
{
|
||||
$at = new stdclass();
|
||||
$at->atMobiles = array($mobile);
|
||||
$at->isAtAll = false;
|
||||
|
||||
$data->msgtype = 'link';
|
||||
$data->link = $link;
|
||||
$data->msgtype = 'text';
|
||||
$data->text = array('content' => $title);
|
||||
$data->at = $at;
|
||||
}
|
||||
else
|
||||
{
|
||||
$link = new stdclass();
|
||||
$link->text = "[#{$objectID}::{$text}]";
|
||||
$link->title = $title;
|
||||
$link->picUrl = '';
|
||||
$link->messageUrl = $host . $viewLink;
|
||||
|
||||
$data->msgtype = 'link';
|
||||
$data->link = $link;
|
||||
}
|
||||
|
||||
return helper::jsonEncode($data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user