From e30bf47d94e84efe42c05148dddd6cec499d12ae Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 19 Apr 2015 19:33:58 -0400 Subject: Rename Hipchat class --- app/Integration/Hipchat.php | 95 ---------------------------- app/Integration/HipchatWebhook.php | 95 ++++++++++++++++++++++++++++ app/ServiceProvider/ClassProvider.php | 2 +- app/Subscriber/ProjectActivitySubscriber.php | 2 +- 4 files changed, 97 insertions(+), 97 deletions(-) delete mode 100644 app/Integration/Hipchat.php create mode 100644 app/Integration/HipchatWebhook.php diff --git a/app/Integration/Hipchat.php b/app/Integration/Hipchat.php deleted file mode 100644 index d0a48e42..00000000 --- a/app/Integration/Hipchat.php +++ /dev/null @@ -1,95 +0,0 @@ -config->get('integration_hipchat') == 1 || $this->projectIntegration->hasValue($project_id, 'hipchat', 1); - } - - /** - * Get API parameters - * - * @access public - * @param integer $project_id - * @return array - */ - public function getParameters($project_id) - { - if ($this->config->get('integration_hipchat') == 1) { - return array( - 'api_url' => $this->config->get('integration_hipchat_api_url'), - 'room_id' => $this->config->get('integration_hipchat_room_id'), - 'room_token' => $this->config->get('integration_hipchat_room_token'), - ); - } - - $options = $this->projectIntegration->getParameters($project_id); - - return array( - 'api_url' => $options['hipchat_api_url'], - 'room_id' => $options['hipchat_room_id'], - 'room_token' => $options['hipchat_room_token'], - ); - } - - /** - * Send the notification if activated - * - * @access public - * @param integer $project_id Project id - * @param integer $task_id Task id - * @param string $event_name Event name - * @param array $event Event data - */ - public function notify($project_id, $task_id, $event_name, array $event) - { - if ($this->isActivated($project_id)) { - - $params = $this->getParameters($project_id); - $project = $this->project->getbyId($project_id); - - $event['event_name'] = $event_name; - $event['author'] = $this->user->getFullname($this->session['user']); - - $html = ''; - $html .= ''.$project['name'].''.(isset($event['task']['title']) ? '
'.$event['task']['title'] : '').'
'; - $html .= $this->projectActivity->getTitle($event); - - if ($this->config->get('application_url')) { - $html .= '
'; - $html .= t('view the task on Kanboard').''; - } - - $payload = array( - 'message' => $html, - 'color' => 'yellow', - ); - - $url = sprintf( - '%s/v2/room/%s/notification?auth_token=%s', - $params['api_url'], - $params['room_id'], - $params['room_token'] - ); - - $this->httpClient->post($url, $payload); - } - } -} diff --git a/app/Integration/HipchatWebhook.php b/app/Integration/HipchatWebhook.php new file mode 100644 index 00000000..03b85232 --- /dev/null +++ b/app/Integration/HipchatWebhook.php @@ -0,0 +1,95 @@ +config->get('integration_hipchat') == 1 || $this->projectIntegration->hasValue($project_id, 'hipchat', 1); + } + + /** + * Get API parameters + * + * @access public + * @param integer $project_id + * @return array + */ + public function getParameters($project_id) + { + if ($this->config->get('integration_hipchat') == 1) { + return array( + 'api_url' => $this->config->get('integration_hipchat_api_url'), + 'room_id' => $this->config->get('integration_hipchat_room_id'), + 'room_token' => $this->config->get('integration_hipchat_room_token'), + ); + } + + $options = $this->projectIntegration->getParameters($project_id); + + return array( + 'api_url' => $options['hipchat_api_url'], + 'room_id' => $options['hipchat_room_id'], + 'room_token' => $options['hipchat_room_token'], + ); + } + + /** + * Send the notification if activated + * + * @access public + * @param integer $project_id Project id + * @param integer $task_id Task id + * @param string $event_name Event name + * @param array $event Event data + */ + public function notify($project_id, $task_id, $event_name, array $event) + { + if ($this->isActivated($project_id)) { + + $params = $this->getParameters($project_id); + $project = $this->project->getbyId($project_id); + + $event['event_name'] = $event_name; + $event['author'] = $this->user->getFullname($this->session['user']); + + $html = ''; + $html .= ''.$project['name'].''.(isset($event['task']['title']) ? '
'.$event['task']['title'] : '').'
'; + $html .= $this->projectActivity->getTitle($event); + + if ($this->config->get('application_url')) { + $html .= '
'; + $html .= t('view the task on Kanboard').''; + } + + $payload = array( + 'message' => $html, + 'color' => 'yellow', + ); + + $url = sprintf( + '%s/v2/room/%s/notification?auth_token=%s', + $params['api_url'], + $params['room_id'], + $params['room_token'] + ); + + $this->httpClient->post($url, $payload); + } + } +} diff --git a/app/ServiceProvider/ClassProvider.php b/app/ServiceProvider/ClassProvider.php index a64ac061..b78eb71a 100644 --- a/app/ServiceProvider/ClassProvider.php +++ b/app/ServiceProvider/ClassProvider.php @@ -76,7 +76,7 @@ class ClassProvider implements ServiceProviderInterface 'GitlabWebhook', 'GithubWebhook', 'BitbucketWebhook', - 'Hipchat', + 'HipchatWebhook', 'MailgunWebhook', 'SendgridWebhook', 'SlackWebhook', diff --git a/app/Subscriber/ProjectActivitySubscriber.php b/app/Subscriber/ProjectActivitySubscriber.php index 696b958b..1c20a996 100644 --- a/app/Subscriber/ProjectActivitySubscriber.php +++ b/app/Subscriber/ProjectActivitySubscriber.php @@ -59,7 +59,7 @@ class ProjectActivitySubscriber extends Base implements EventSubscriberInterface private function sendHipchatNotification($event_name, array $values) { - $this->hipchat->notify( + $this->hipchatWebhook->notify( $values['task']['project_id'], $values['task']['id'], $event_name, -- cgit v1.2.3