diff options
Diffstat (limited to 'app/Integration/SlackWebhook.php')
-rw-r--r-- | app/Integration/SlackWebhook.php | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/app/Integration/SlackWebhook.php b/app/Integration/SlackWebhook.php index 975ea21f..d238652f 100644 --- a/app/Integration/SlackWebhook.php +++ b/app/Integration/SlackWebhook.php @@ -40,6 +40,25 @@ class SlackWebhook extends \Core\Base } /** + * Get optional Slack channel + * + * @access public + * @param integer $project_id + * @return string + */ + public function getChannel($project_id) + { + $channel = $this->config->get('integration_slack_webhook_channel'); + + if (! empty($channel)) { + return $channel; + } + + $options = $this->projectIntegration->getParameters($project_id); + return $options['slack_webhook_channel']; + } + + /** * Send message to the incoming Slack webhook * * @access public @@ -64,11 +83,15 @@ class SlackWebhook extends \Core\Base ); if ($this->config->get('application_url')) { - $payload['text'] .= ' - <'.$this->config->get('application_url'); - $payload['text'] .= $this->helper->url->href('task', 'show', array('task_id' => $task_id, 'project_id' => $project_id)); + $payload['text'] .= ' - <'.$this->helper->url->href('task', 'show', array('task_id' => $task_id, 'project_id' => $project_id), false, '', true); $payload['text'] .= '|'.t('view the task on Kanboard').'>'; } + $channel = $this->getChannel($project_id); + if (! empty($channel)) { + $payload['channel'] = $channel; + } + $this->httpClient->postJson($this->getWebhookUrl($project_id), $payload); } } |