Skip to content

Commit

Permalink
Refactoring user ID list to send mails - refs BT#21648
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelFQC committed May 26, 2024
1 parent 0da3b71 commit 8472948
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions src/CoreBundle/State/MessageProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use ApiPlatform\Metadata\Post;
use ApiPlatform\State\ProcessorInterface;
use Chamilo\CoreBundle\Entity\Message;
use Chamilo\CoreBundle\Entity\MessageRelUser;
use Notification;

final class MessageProcessor implements ProcessorInterface
Expand Down Expand Up @@ -45,19 +46,21 @@ private function saveNotificationForInboxMessage(Message $message): void
$message->getSender()->getId()
);

foreach ($message->getReceivers() as $receiver) {
$user = $receiver->getReceiver();

(new Notification())
->saveNotification(
$message->getId(),
Notification::NOTIFICATION_TYPE_MESSAGE,
[$user->getId()],
$message->getTitle(),
$message->getContent(),
$sender_info,
)
;
}
$userIdList = $message
->getReceivers()
->map(fn (MessageRelUser $messageRelUser): int => $messageRelUser->getReceiver()->getId())
->getValues()
;

(new Notification())
->saveNotification(
$message->getId(),
Notification::NOTIFICATION_TYPE_MESSAGE,
$userIdList,
$message->getTitle(),
$message->getContent(),
$sender_info,
)
;
}
}

0 comments on commit 8472948

Please sign in to comment.