Make sure that some event subscribers are not executed multiple times
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Kanboard\Subscriber;
|
||||
|
||||
use Kanboard\Core\Base;
|
||||
use Kanboard\Event\GenericEvent;
|
||||
use Kanboard\Model\Task;
|
||||
use Kanboard\Model\Comment;
|
||||
@@ -10,7 +9,7 @@ use Kanboard\Model\Subtask;
|
||||
use Kanboard\Model\File;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
class NotificationSubscriber extends Base implements EventSubscriberInterface
|
||||
class NotificationSubscriber extends BaseSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
@@ -35,14 +34,17 @@ class NotificationSubscriber extends Base implements EventSubscriberInterface
|
||||
|
||||
public function handleEvent(GenericEvent $event, $event_name)
|
||||
{
|
||||
$event_data = $this->getEventData($event);
|
||||
if (! $this->isExecuted()) {
|
||||
$this->logger->debug('Subscriber executed: '.__CLASS__.'::'.__METHOD__);
|
||||
$event_data = $this->getEventData($event);
|
||||
|
||||
if (! empty($event_data)) {
|
||||
if (! empty($event['mention'])) {
|
||||
$this->userNotification->sendUserNotification($event['mention'], $event_name, $event_data);
|
||||
} else {
|
||||
$this->userNotification->sendNotifications($event_name, $event_data);
|
||||
$this->projectNotification->sendNotifications($event_data['task']['project_id'], $event_name, $event_data);
|
||||
if (! empty($event_data)) {
|
||||
if (! empty($event['mention'])) {
|
||||
$this->userNotification->sendUserNotification($event['mention'], $event_name, $event_data);
|
||||
} else {
|
||||
$this->userNotification->sendNotifications($event_name, $event_data);
|
||||
$this->projectNotification->sendNotifications($event_data['task']['project_id'], $event_name, $event_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user