mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
NotificationMailer: send to correct destinees
This commit is contained in:
parent
f3fbd5314a
commit
40a72d9fca
@ -1,6 +0,0 @@
|
|||||||
kind: Fixed
|
|
||||||
body: Fix who receive reply notification when adding comment (recipees must receive
|
|
||||||
it, and sender not).
|
|
||||||
time: 2023-08-24T15:20:38.472382872+02:00
|
|
||||||
custom:
|
|
||||||
Issue: "137"
|
|
5
.changes/unreleased/Fixed-20230906-154856.yaml
Normal file
5
.changes/unreleased/Fixed-20230906-154856.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
kind: Fixed
|
||||||
|
body: Do not send an email to creator twice when adding a comment to a notification
|
||||||
|
time: 2023-09-06T15:48:56.991246312+02:00
|
||||||
|
custom:
|
||||||
|
Issue: ""
|
@ -40,13 +40,18 @@ class NotificationMailer
|
|||||||
|
|
||||||
public function postPersistComment(NotificationComment $comment, PostPersistEventArgs $eventArgs): void
|
public function postPersistComment(NotificationComment $comment, PostPersistEventArgs $eventArgs): void
|
||||||
{
|
{
|
||||||
foreach (
|
$dests = [$comment->getNotification()->getSender(), ...$comment->getNotification()->getAddressees()->toArray()];
|
||||||
array_merge(
|
|
||||||
$comment->getNotification()->getAddressees()->toArray(),
|
$uniqueDests = [];
|
||||||
[$comment->getNotification()->getSender()]
|
foreach ($dests as $dest) {
|
||||||
) as $dest
|
// avoid duplication
|
||||||
) {
|
if (in_array(spl_object_hash($dest), $uniqueDests, true)) {
|
||||||
if (null !== $dest->getEmail() && $comment->getCreatedBy() === $dest) {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
$email = new TemplatedEmail();
|
$email = new TemplatedEmail();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user