Skip to content

Commit

Permalink
Merge pull request #8 from adrianodias8/#7_check_entity_isSyncing
Browse files Browse the repository at this point in the history
prevent dispatching activity events if entity isSyncing
  • Loading branch information
adrianodias8 authored Apr 1, 2020
2 parents 96f0da5 + a469080 commit 2d5ab8c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/EventSubscriber/ActivitySubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,15 @@ public function scheduleDecay(CronEvent $event) {
*/
public function dispatchActivityEvent(Event $event) {
// TODO: IMPROVE THIS FIRST CONDITION!!
if (in_array($event->getEntity()->getEntityTypeId(), EntityActivityTrackerInterface::ALLOWED_ENTITY_TYPES)) {
// Dispatch corresponding activity event.
$this->activityEventDispatcher->dispatchActivityEvent($event);

// TODO: Think a way to hook this. to let other modules play.
$entity = $event->getEntity();
// Syncing entities should not count.
// @see: GroupContent::postSave()
if (!$entity->isSyncing()) {
if (in_array($entity->getEntityTypeId(), EntityActivityTrackerInterface::ALLOWED_ENTITY_TYPES)) {
// Dispatch corresponding activity event.
$this->activityEventDispatcher->dispatchActivityEvent($event);
// TODO: Think a way to hook this. to let other modules play.
}
}
}

Expand Down

0 comments on commit 2d5ab8c

Please sign in to comment.