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/Model/ProjectActivity.php | 8 +++++++- app/Model/Webhook.php | 39 +-------------------------------------- 2 files changed, 8 insertions(+), 39 deletions(-) (limited to 'app/Model') diff --git a/app/Model/ProjectActivity.php b/app/Model/ProjectActivity.php index 652cc842..c5fbbd38 100644 --- a/app/Model/ProjectActivity.php +++ b/app/Model/ProjectActivity.php @@ -162,7 +162,13 @@ class ProjectActivity extends Base { switch ($event['event_name']) { case Task::EVENT_ASSIGNEE_CHANGE: - return t('%s change the assignee of the task #%d to %s', $event['author'], $event['task']['id'], $event['task']['assignee_name'] ?: $event['task']['assignee_username']); + $assignee = $event['task']['assignee_name'] ?: $event['task']['assignee_username']; + + if (! empty($assignee)) { + return t('%s change the assignee of the task #%d to %s', $event['author'], $event['task']['id'], $assignee); + } + + return t('%s remove the assignee of the task %s', $event['author'], e('#%d', $event['task']['id'])); case Task::EVENT_UPDATE: return t('%s updated the task #%d', $event['author'], $event['task']['id']); case Task::EVENT_CREATE: diff --git a/app/Model/Webhook.php b/app/Model/Webhook.php index 7edffa6e..b3603818 100644 --- a/app/Model/Webhook.php +++ b/app/Model/Webhook.php @@ -10,27 +10,6 @@ namespace Model; */ class Webhook extends Base { - /** - * HTTP connection timeout in seconds - * - * @var integer - */ - const HTTP_TIMEOUT = 1; - - /** - * Number of maximum redirections for the HTTP client - * - * @var integer - */ - const HTTP_MAX_REDIRECTS = 3; - - /** - * HTTP client user agent - * - * @var string - */ - const HTTP_USER_AGENT = 'Kanboard Webhook'; - /** * Call the external URL * @@ -42,22 +21,6 @@ class Webhook extends Base { $token = $this->config->get('webhook_token'); - $headers = array( - 'Connection: close', - 'User-Agent: '.self::HTTP_USER_AGENT, - ); - - $context = stream_context_create(array( - 'http' => array( - 'method' => 'POST', - 'protocol_version' => 1.1, - 'timeout' => self::HTTP_TIMEOUT, - 'max_redirects' => self::HTTP_MAX_REDIRECTS, - 'header' => implode("\r\n", $headers), - 'content' => json_encode($task) - ) - )); - if (strpos($url, '?') !== false) { $url .= '&token='.$token; } @@ -65,6 +28,6 @@ class Webhook extends Base $url .= '?token='.$token; } - @file_get_contents($url, false, $context); + return $this->httpClient->post($url, $task); } } -- cgit v1.2.3