fix: check activity settings only when user account exists

When identification method is email and person has no account,
notification was being blocked by activity check for non-existent user.
Now checks if user exists before verifying activity notification settings.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
This commit is contained in:
Vitor Mattos 2025-12-11 15:05:56 -03:00
commit 3277ae6d4a
No known key found for this signature in database
GPG key ID: 6FECE2AD4809003A

View file

@ -60,13 +60,11 @@ class MailNotifyListener implements IEventListener {
if ($identifyMethod->getEntity()->isDeletedAccount()) { if ($identifyMethod->getEntity()->isDeletedAccount()) {
return; return;
} }
if ($this->isNotificationDisabledAtActivity($identifyMethod->getEntity()->getIdentifierValue(), SendSignNotificationEvent::FILE_TO_SIGN)) {
return;
}
$email = ''; $email = '';
if ($identifyMethod->getName() === 'account') { if ($identifyMethod->getName() === 'account') {
$userId = $identifyMethod->getEntity()->getIdentifierValue();
$email = $this->userManager $email = $this->userManager
->get($identifyMethod->getEntity()->getIdentifierValue()) ->get($userId)
->getEMailAddress(); ->getEMailAddress();
} elseif ($identifyMethod->getName() === 'email') { } elseif ($identifyMethod->getName() === 'email') {
$email = $identifyMethod->getEntity()->getIdentifierValue(); $email = $identifyMethod->getEntity()->getIdentifierValue();
@ -74,6 +72,15 @@ class MailNotifyListener implements IEventListener {
if (empty($email)) { if (empty($email)) {
return; 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'); $isFirstNotification = $this->signRequestMapper->incrementNotificationCounter($signRequest, 'mail');
if ($isFirstNotification) { if ($isFirstNotification) {
$this->mail->notifyUnsignedUser($signRequest, $email); $this->mail->notifyUnsignedUser($signRequest, $email);