summaryrefslogtreecommitdiff
path: root/app/Integration
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-03-28 21:37:53 -0400
committerFrederic Guillot <fred@kanboard.net>2015-03-28 21:37:53 -0400
commit5536f6c6ce591ba05a169d2e33b6fb240378d8a4 (patch)
treebac0cb1563d8258965384b97be8d425578f71ef6 /app/Integration
parentf9891a966fb87d2112f174b7c3a1b3a705b73bdd (diff)
Add Slack integration
Diffstat (limited to 'app/Integration')
-rw-r--r--app/Integration/SlackWebhook.php43
1 files changed, 43 insertions, 0 deletions
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 @@
+<?php
+
+namespace Integration;
+
+/**
+ * Slack Webhook
+ *
+ * @package integration
+ * @author Frederic Guillot
+ */
+class SlackWebhook extends Base
+{
+ /**
+ * Send message to the incoming Slack webhook
+ *
+ * @access public
+ * @param integer $project_id Project id
+ * @param integer $task_id Task id
+ * @param string $event_name Event name
+ * @param array $data Event data
+ */
+ public function notify($project_id, $task_id, $event_name, array $event)
+ {
+ $project = $this->project->getbyId($project_id);
+
+ $event['event_name'] = $event_name;
+ $event['author'] = $this->user->getFullname($this->session['user']);
+
+ $payload = array(
+ 'text' => '*['.$project['name'].']* '.str_replace('&quot;', '"', $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);
+ }
+}