Skip to content

Commit

Permalink
* Support markdown for feishu webhook.
Browse files Browse the repository at this point in the history
  • Loading branch information
sy-records authored and 朱金勇 committed Apr 3, 2023
1 parent f5b0a2f commit 37445a4
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions module/webhook/model.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,33 @@ class webhookModel extends model
*/
public function getByID($id)
{
$webhook = $this->dao->select('*')->from(TABLE_WEBHOOK)->where('id')->eq($id)->fetch();
return $webhook;
return $this->dao->select('*')->from(TABLE_WEBHOOK)->where('id')->eq($id)->fetch();
}

/**
* Get a webhook by type.
*
* @param int $type
* @param string $type
* @access public
* @return object
*/
public function getByType($type)
{
$webhook = $this->dao->select('*')->from(TABLE_WEBHOOK)->where('type')->eq($type)->andWhere('deleted')->eq('0')->fetch();
return $webhook;
return $this->dao->select('*')->from(TABLE_WEBHOOK)->where('type')->eq($type)->andWhere('deleted')->eq('0')->fetch();
}

/**
* Get a webhook by type.
*
* @param int $type
* @param int $webhookID
* @param string $webhookType
* @param string $openID
* @access public
* @return object
*/
public function getBindAccount($webhookID, $webhookType, $openID)
{
$account = $this->dao->select('account')->from(TABLE_OAUTH)->where('providerID')->eq($webhookID)->andWhere('providerType')->eq($webhookType)->andWhere('openID')->eq($openID)->fetch('account');
return $account;
return $this->dao->select('account')->from(TABLE_OAUTH)->where('providerID')->eq($webhookID)->andWhere('providerType')->eq($webhookType)->andWhere('openID')->eq($openID)->fetch('account');
}

/**
Expand All @@ -61,12 +60,11 @@ public function getBindAccount($webhookID, $webhookType, $openID)
*/
public function getList($orderBy = 'id_desc', $pager = null, $decode = true)
{
$webhooks = $this->dao->select('*')->from(TABLE_WEBHOOK)
return $this->dao->select('*')->from(TABLE_WEBHOOK)
->where('deleted')->eq('0')
->orderBy($orderBy)
->page($pager)
->fetchAll('id');
return $webhooks;
}

/**
Expand Down Expand Up @@ -354,6 +352,7 @@ public function bind($webhookID)
* @param int $objectID
* @param string $actionType
* @param int $actionID
* @param string $actor
* @access public
* @return bool
*/
Expand Down Expand Up @@ -609,15 +608,23 @@ public function getWeixinData($title, $text, $mobile = '')
public function getFeishuData($title, $text)
{
$data = new stdclass();
$data->msg_type = 'text';
$data->content['text'] = $text;
$data->msg_type = 'interactive';

$data->card = array();
$data->card['header'] = array();
$data->card['elements'] = array();

$data->card['elements'][] = array('tag' => 'markdown', 'content' => $text);
$data->card['header']['title'] = array('tag' => 'plain_text', 'content' => $title);
$data->card['header']['template'] = 'blue';

return $data;
}

/**
* Get openID list.
*
* @param int $webhookID
* @param int $actionID
* @access public
* @return string
Expand Down Expand Up @@ -742,6 +749,7 @@ public function fetchHook($webhook, $sendData, $actionID = 0)
* @param int $webhookID
* @param int $actionID
* @param string $data
* @param string $actor
* @access public
* @return bool
*/
Expand Down

0 comments on commit 37445a4

Please sign in to comment.