diff options
author | Ash Bike <hello.ashbike@gmail.com> | 2015-07-05 02:16:18 +0530 |
---|---|---|
committer | Ash Bike <hello.ashbike@gmail.com> | 2015-07-05 02:16:18 +0530 |
commit | bc6b443c3db4f260bdc1460009c8110b54b3c257 (patch) | |
tree | f9028a240fe27325b6d8da84824258fd19828aae /app/Integration/SlackWebhook.php | |
parent | 33669c1bac974f87fa8a3809cb541d75e26fd3ef (diff) |
Slack channel can be overridden to post to another channel/private group or send direct messages. Need to make these database changes:
INSERT INTO settings VALUES ('integration_slack_webhook_channel', '');
ALTER TABLE project_integrations ADD COLUMN slack_webhook_channel text;
Diffstat (limited to 'app/Integration/SlackWebhook.php')
-rw-r--r-- | app/Integration/SlackWebhook.php | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/app/Integration/SlackWebhook.php b/app/Integration/SlackWebhook.php index 975ea21f..a584c132 100644 --- a/app/Integration/SlackWebhook.php +++ b/app/Integration/SlackWebhook.php @@ -38,6 +38,23 @@ class SlackWebhook extends \Core\Base $options = $this->projectIntegration->getParameters($project_id); return $options['slack_webhook_url']; } + + /** + * Get optional Slack channel + * + * @access public + * @param integer $project_id + * @return string + */ + public function getChannel($project_id) + { + if (!empty($this->config->get('integration_slack_webhook_channel'))) { + return $this->config->get('integration_slack_webhook_channel'); + } + + $options = $this->projectIntegration->getParameters($project_id); + return $options['slack_webhook_channel']; + } /** * Send message to the incoming Slack webhook @@ -68,6 +85,11 @@ class SlackWebhook extends \Core\Base $payload['text'] .= $this->helper->url->href('task', 'show', array('task_id' => $task_id, 'project_id' => $project_id)); $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); } |