mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-22 15:43:51 +00:00
NotificationMailer: send to correct destinees
This commit is contained in:
@@ -40,13 +40,18 @@ class NotificationMailer
|
||||
|
||||
public function postPersistComment(NotificationComment $comment, PostPersistEventArgs $eventArgs): void
|
||||
{
|
||||
foreach (
|
||||
array_merge(
|
||||
$comment->getNotification()->getAddressees()->toArray(),
|
||||
[$comment->getNotification()->getSender()]
|
||||
) as $dest
|
||||
) {
|
||||
if (null !== $dest->getEmail() && $comment->getCreatedBy() === $dest) {
|
||||
$dests = [$comment->getNotification()->getSender(), ...$comment->getNotification()->getAddressees()->toArray()];
|
||||
|
||||
$uniqueDests = [];
|
||||
foreach ($dests as $dest) {
|
||||
// avoid duplication
|
||||
if (in_array(spl_object_hash($dest), $uniqueDests, true)) {
|
||||
continue;
|
||||
}
|
||||
$uniqueDests[] = spl_object_hash($dest);
|
||||
|
||||
// do not send if the sender does not have any email, nor to the creator of the comment
|
||||
if (null === $dest->getEmail() || $comment->getCreatedBy() === $dest) {
|
||||
continue;
|
||||
}
|
||||
$email = new TemplatedEmail();
|
||||
|
Reference in New Issue
Block a user