Commit b7e857b0 authored by Navneet Singh's avatar Navneet Singh Committed by Navneet Singh
Browse files

Merge pull request #2766 from goalgorilla/issue/3264208

Issue #3264208 by tBKoT: Do not send emails if related content does not exist
parent 83c33be0
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -2,12 +2,12 @@

namespace Drupal\activity_send_email\Plugin\EmailFrequency;

use Drupal\activity_creator\Entity\Activity;
use Drupal\activity_creator\ActivityInterface;
use Drupal\activity_send_email\EmailFrequencyBase;
use Drupal\activity_send_email\Plugin\ActivityDestination\EmailActivityDestination;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\message\Entity\Message;
use Drupal\message\MessageInterface;
use Drupal\user\Entity\User;

/**
@@ -25,9 +25,9 @@ class Immediately extends EmailFrequencyBase {
  /**
   * {@inheritdoc}
   */
  public function processItem(Activity $activity, Message $message, User $target, $body_text = NULL) {
  public function processItem(ActivityInterface $activity, MessageInterface $message, User $target, $body_text = NULL) {
    // If the user is blocked, we don't want to process this item further.
    if ($target->isBlocked()) {
    if ($target->isBlocked() || $activity->getRelatedEntity() === NULL) {
      return;
    }

+4 −4
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@

namespace Drupal\activity_send_email\Plugin\QueueWorker;

use Drupal\activity_creator\Entity\Activity;
use Drupal\activity_creator\ActivityInterface;
use Drupal\activity_send\Plugin\QueueWorker\ActivitySendWorkerBase;
use Drupal\activity_send_email\EmailFrequencyManager;
use Drupal\activity_send_email\Plugin\ActivityDestination\EmailActivityDestination;
@@ -132,9 +132,9 @@ class ActivityDigestWorker extends ActivitySendWorkerBase implements ContainerFa

          // Only for users that have access to related content.
          if (
            ($activity instanceof Activity) &&
            ($activity->getRelatedEntity() !== NULL) &&
            ($activity->getRelatedEntity()->access('view', $target) === FALSE)
            !($activity instanceof ActivityInterface) ||
            ($related_entity = $activity->getRelatedEntity()) === NULL ||
            !$related_entity->access('view', $target)
          ) {
            continue;
          }