summaryrefslogtreecommitdiff
path: root/app/Job/NotificationJob.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Job/NotificationJob.php')
-rw-r--r--app/Job/NotificationJob.php60
1 files changed, 9 insertions, 51 deletions
diff --git a/app/Job/NotificationJob.php b/app/Job/NotificationJob.php
index 904a9273..8fb260e8 100644
--- a/app/Job/NotificationJob.php
+++ b/app/Job/NotificationJob.php
@@ -17,69 +17,27 @@ class NotificationJob extends BaseJob
*
* @param GenericEvent $event
* @param string $eventName
- * @param string $eventObjectName
* @return $this
*/
- public function withParams(GenericEvent $event, $eventName, $eventObjectName)
+ public function withParams(GenericEvent $event, $eventName)
{
- $this->jobParams = array($event->getAll(), $eventName, $eventObjectName);
+ $this->jobParams = array($event->getAll(), $eventName);
return $this;
}
/**
* Execute job
*
- * @param array $event
+ * @param array $eventData
* @param string $eventName
- * @param string $eventObjectName
*/
- public function execute(array $event, $eventName, $eventObjectName)
+ public function execute(array $eventData, $eventName)
{
- $eventData = $this->getEventData($event, $eventObjectName);
-
- if (! empty($eventData)) {
- if (! empty($event['mention'])) {
- $this->userNotificationModel->sendUserNotification($event['mention'], $eventName, $eventData);
- } else {
- $this->userNotificationModel->sendNotifications($eventName, $eventData);
- $this->projectNotificationModel->sendNotifications($eventData['task']['project_id'], $eventName, $eventData);
- }
- }
- }
-
- /**
- * Get event data
- *
- * @param array $event
- * @param string $eventObjectName
- * @return array
- */
- public function getEventData(array $event, $eventObjectName)
- {
- $values = array();
-
- if (! empty($event['changes'])) {
- $values['changes'] = $event['changes'];
+ if (! empty($eventData['mention'])) {
+ $this->userNotificationModel->sendUserNotification($eventData['mention'], $eventName, $eventData);
+ } else {
+ $this->userNotificationModel->sendNotifications($eventName, $eventData);
+ $this->projectNotificationModel->sendNotifications($eventData['task']['project_id'], $eventName, $eventData);
}
-
- switch ($eventObjectName) {
- case 'Kanboard\Event\TaskEvent':
- $values['task'] = $this->taskFinderModel->getDetails($event['task_id']);
- break;
- case 'Kanboard\Event\SubtaskEvent':
- $values['subtask'] = $this->subtaskModel->getById($event['id'], true);
- $values['task'] = $this->taskFinderModel->getDetails($values['subtask']['task_id']);
- break;
- case 'Kanboard\Event\FileEvent':
- $values['file'] = $event;
- $values['task'] = $this->taskFinderModel->getDetails($values['file']['task_id']);
- break;
- case 'Kanboard\Event\CommentEvent':
- $values['comment'] = $this->commentModel->getById($event['id']);
- $values['task'] = $this->taskFinderModel->getDetails($values['comment']['task_id']);
- break;
- }
-
- return $values;
}
}