From 9153c6ff0ddb3170928d33599d9178e67ca466b6 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 17 Oct 2015 12:53:11 -0400 Subject: Move ProjectActivitySubscriber to a new notification type --- app/Subscriber/ProjectActivitySubscriber.php | 74 ---------------------------- 1 file changed, 74 deletions(-) delete mode 100644 app/Subscriber/ProjectActivitySubscriber.php (limited to 'app/Subscriber') diff --git a/app/Subscriber/ProjectActivitySubscriber.php b/app/Subscriber/ProjectActivitySubscriber.php deleted file mode 100644 index a49a00ed..00000000 --- a/app/Subscriber/ProjectActivitySubscriber.php +++ /dev/null @@ -1,74 +0,0 @@ - array('execute', 0), - Task::EVENT_UPDATE => array('execute', 0), - Task::EVENT_CREATE => array('execute', 0), - Task::EVENT_CLOSE => array('execute', 0), - Task::EVENT_OPEN => array('execute', 0), - Task::EVENT_MOVE_COLUMN => array('execute', 0), - Task::EVENT_MOVE_POSITION => array('execute', 0), - Task::EVENT_MOVE_SWIMLANE => array('execute', 0), - Comment::EVENT_UPDATE => array('execute', 0), - Comment::EVENT_CREATE => array('execute', 0), - Subtask::EVENT_UPDATE => array('execute', 0), - Subtask::EVENT_CREATE => array('execute', 0), - ); - } - - public function execute(GenericEvent $event, $event_name) - { - // Executed only when someone is logged - if ($this->userSession->isLogged() && isset($event['task_id'])) { - $values = $this->getValues($event); - - $this->projectActivity->createEvent( - $values['task']['project_id'], - $values['task']['id'], - $this->userSession->getId(), - $event_name, - $values - ); - - // Send notifications to third-party services - foreach (array('slackWebhook', 'hipchatWebhook', 'jabber') as $model) { - $this->$model->notify( - $values['task']['project_id'], - $values['task']['id'], - $event_name, - $values - ); - } - } - } - - private function getValues(GenericEvent $event) - { - $values = array(); - $values['task'] = $this->taskFinder->getDetails($event['task_id']); - $values['changes'] = isset($event['changes']) ? $event['changes'] : array(); - - switch (get_class($event)) { - case 'Kanboard\Event\SubtaskEvent': - $values['subtask'] = $this->subtask->getById($event['id'], true); - break; - case 'Kanboard\Event\CommentEvent': - $values['comment'] = $this->comment->getById($event['id']); - break; - } - - return $values; - } -} -- cgit v1.2.3