From ec0ecc5b0387924f061865f4ec12dbfc5b7018fe Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 17 Jul 2016 17:15:14 -0400 Subject: Added event for removed comments with some refactoring --- app/Job/CommentEventJob.php | 50 +++++++++++++++++++++++++++++++++++++++++++++ app/Job/NotificationJob.php | 3 +-- 2 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 app/Job/CommentEventJob.php (limited to 'app/Job') diff --git a/app/Job/CommentEventJob.php b/app/Job/CommentEventJob.php new file mode 100644 index 00000000..c89350ed --- /dev/null +++ b/app/Job/CommentEventJob.php @@ -0,0 +1,50 @@ +jobParams = array($commentId, $eventName); + return $this; + } + + /** + * Execute job + * + * @param int $commentId + * @param string $eventName + * @return $this + */ + public function execute($commentId, $eventName) + { + $event = CommentEventBuilder::getInstance($this->container) + ->withCommentId($commentId) + ->build(); + + if ($event !== null) { + $this->dispatcher->dispatch($eventName, $event); + + if ($eventName === CommentModel::EVENT_CREATE) { + $this->userMentionModel->fireEvents($event['comment']['comment'], CommentModel::EVENT_USER_MENTION, $event); + } + } + } +} diff --git a/app/Job/NotificationJob.php b/app/Job/NotificationJob.php index 904a9273..cfd0699d 100644 --- a/app/Job/NotificationJob.php +++ b/app/Job/NotificationJob.php @@ -75,8 +75,7 @@ class NotificationJob extends BaseJob $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']); + $values = $event; break; } -- cgit v1.2.3