From 5536f6c6ce591ba05a169d2e33b6fb240378d8a4 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 28 Mar 2015 21:37:53 -0400 Subject: Add Slack integration --- app/Integration/SlackWebhook.php | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 app/Integration/SlackWebhook.php (limited to 'app/Integration/SlackWebhook.php') diff --git a/app/Integration/SlackWebhook.php b/app/Integration/SlackWebhook.php new file mode 100644 index 00000000..fc7daeb4 --- /dev/null +++ b/app/Integration/SlackWebhook.php @@ -0,0 +1,43 @@ +project->getbyId($project_id); + + $event['event_name'] = $event_name; + $event['author'] = $this->user->getFullname($this->session['user']); + + $payload = array( + 'text' => '*['.$project['name'].']* '.str_replace('"', '"', $this->projectActivity->getTitle($event)), + 'username' => 'Kanboard', + 'icon_url' => 'http://kanboard.net/assets/img/favicon.png', + ); + + if ($this->config->get('application_url')) { + $payload['text'] .= ' - <'.$this->config->get('application_url'); + $payload['text'] .= $this->helper->u('task', 'show', array('task_id' => $task_id, 'project_id' => $project_id)); + $payload['text'] .= '|'.t('view the task on Kanboard').'>'; + } + + $this->httpClient->post($this->config->get('integration_slack_webhook_url'), $payload); + } +} -- cgit v1.2.3