diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-10-17 12:30:05 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-10-17 12:30:05 -0400 |
commit | 472f94efee77d8f47ece4ead7d36ee02e5df3e56 (patch) | |
tree | 3456ca052db268b1477aa8b9a741d14bb9927515 /app/Subscriber | |
parent | 3543f45c2d4d6e96e5b88c3168075c0d583fc261 (diff) |
Move webhook to project notification type
Diffstat (limited to 'app/Subscriber')
-rw-r--r-- | app/Subscriber/NotificationSubscriber.php | 12 | ||||
-rw-r--r-- | app/Subscriber/ProjectActivitySubscriber.php | 4 | ||||
-rw-r--r-- | app/Subscriber/WebhookSubscriber.php | 45 |
3 files changed, 12 insertions, 49 deletions
diff --git a/app/Subscriber/NotificationSubscriber.php b/app/Subscriber/NotificationSubscriber.php index 07ce00a1..394573e4 100644 --- a/app/Subscriber/NotificationSubscriber.php +++ b/app/Subscriber/NotificationSubscriber.php @@ -32,17 +32,25 @@ class NotificationSubscriber extends \Kanboard\Core\Base implements EventSubscri public function execute(GenericEvent $event, $event_name) { - $this->userNotification->sendNotifications($event_name, $this->getEventData($event)); + $event_data = $this->getEventData($event); + + if (! empty($event_data)) { + $this->userNotification->sendNotifications($event_name, $event_data); + $this->projectNotification->sendNotifications($event_data['task']['project_id'], $event_name, $event_data); + } } public function getEventData(GenericEvent $event) { $values = array(); + if (! empty($event['changes'])) { + $values['changes'] = $event['changes']; + } + switch (get_class($event)) { case 'Kanboard\Event\TaskEvent': $values['task'] = $this->taskFinder->getDetails($event['task_id']); - $values['changes'] = isset($event['changes']) ? $event['changes'] : array(); break; case 'Kanboard\Event\SubtaskEvent': $values['subtask'] = $this->subtask->getById($event['id'], true); diff --git a/app/Subscriber/ProjectActivitySubscriber.php b/app/Subscriber/ProjectActivitySubscriber.php index a66bbc5a..a49a00ed 100644 --- a/app/Subscriber/ProjectActivitySubscriber.php +++ b/app/Subscriber/ProjectActivitySubscriber.php @@ -61,10 +61,10 @@ class ProjectActivitySubscriber extends \Kanboard\Core\Base implements EventSubs $values['changes'] = isset($event['changes']) ? $event['changes'] : array(); switch (get_class($event)) { - case 'Event\SubtaskEvent': + case 'Kanboard\Event\SubtaskEvent': $values['subtask'] = $this->subtask->getById($event['id'], true); break; - case 'Event\CommentEvent': + case 'Kanboard\Event\CommentEvent': $values['comment'] = $this->comment->getById($event['id']); break; } diff --git a/app/Subscriber/WebhookSubscriber.php b/app/Subscriber/WebhookSubscriber.php deleted file mode 100644 index 8a2bd080..00000000 --- a/app/Subscriber/WebhookSubscriber.php +++ /dev/null @@ -1,45 +0,0 @@ -<?php - -namespace Kanboard\Subscriber; - -use Kanboard\Event\CommentEvent; -use Kanboard\Event\GenericEvent; -use Kanboard\Event\TaskEvent; -use Kanboard\Model\Comment; -use Kanboard\Model\Task; -use Kanboard\Model\File; -use Kanboard\Model\Subtask; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -class WebhookSubscriber extends \Kanboard\Core\Base implements EventSubscriberInterface -{ - public static function getSubscribedEvents() - { - return array( - Task::EVENT_CREATE => array('execute', 0), - Task::EVENT_UPDATE => 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_ASSIGNEE_CHANGE => array('execute', 0), - Task::EVENT_MOVE_PROJECT => array('execute', 0), - Task::EVENT_MOVE_SWIMLANE => array('execute', 0), - Comment::EVENT_CREATE => array('execute', 0), - Comment::EVENT_UPDATE => array('execute', 0), - File::EVENT_CREATE => array('execute', 0), - Subtask::EVENT_CREATE => array('execute', 0), - Subtask::EVENT_UPDATE => array('execute', 0), - ); - } - - public function execute(GenericEvent $event, $event_name) - { - $payload = array( - 'event_name' => $event_name, - 'event_data' => $event->getAll(), - ); - - $this->webhook->notify($payload); - } -} |