diff --git a/lib/Listener/MailNotifyListener.php b/lib/Listener/MailNotifyListener.php index e5544728b5..36e405f8d5 100644 --- a/lib/Listener/MailNotifyListener.php +++ b/lib/Listener/MailNotifyListener.php @@ -59,13 +59,11 @@ protected function sendSignMailNotification( if ($identifyMethod->getEntity()->isDeletedAccount()) { return; } - if ($this->isNotificationDisabledAtActivity($identifyMethod->getEntity()->getIdentifierValue(), SendSignNotificationEvent::FILE_TO_SIGN)) { - return; - } $email = ''; if ($identifyMethod->getName() === 'account') { + $userId = $identifyMethod->getEntity()->getIdentifierValue(); $email = $this->userManager - ->get($identifyMethod->getEntity()->getIdentifierValue()) + ->get($userId) ->getEMailAddress(); } elseif ($identifyMethod->getName() === 'email') { $email = $identifyMethod->getEntity()->getIdentifierValue(); @@ -73,6 +71,15 @@ protected function sendSignMailNotification( if (empty($email)) { return; } + + $users = $this->userManager->getByEmail($email); + if (count($users) === 1) { + $userId = $users[0]->getUID(); + if ($this->isNotificationDisabledAtActivity($userId, SendSignNotificationEvent::FILE_TO_SIGN)) { + return; + } + } + $isFirstNotification = $this->signRequestMapper->incrementNotificationCounter($signRequest, 'mail'); if ($isFirstNotification) { $this->mail->notifyUnsignedUser($signRequest, $email);