From 2c51ddf86f97fcdd59d5051c03e5438f93c05471 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Thu, 12 Nov 2026 12:37:35 +0100 Subject: [PATCH] feat: send replies to assignment mailings to the travel management inbox --- .env | 4 ++++ config/services.yaml | 2 ++ src/Message/SendTeamerMailing.php | 4 ++-- src/Service/Teamer/AssignmentMailingService.php | 5 +++-- .../AssignmentMailing/AssignmentMailingControllerTest.php | 7 ++----- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.env b/.env index 2cc7c76..b28fc6d 100644 --- a/.env +++ b/.env @@ -70,6 +70,10 @@ APP_BPN_CRM_ID_TEAMER=1070 APP_DEFAULT_EMAIL_FROM=team@ep-reisen.de APP_DEFAULT_EMAIL_TO=team@ep-reisen.de +# Reply-To of every mail of an assignment mailing, so answers reach the shared inbox rather +# than the manager who happened to send it. +APP_ASSIGNMENT_MAILING_REPLY_TO=reisemanagement@ep-reisen.de + # Regular expressions of the only recipients a mail may actually reach. Everything else is # stripped from the envelope and a mail left without a recipient is not sent at all, see # App\EventListener\EmailRecipientWhitelistSubscriber. Empty means no filtering, which is what diff --git a/config/services.yaml b/config/services.yaml index 974ebed..d3c34da 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -78,6 +78,7 @@ parameters: default_email_from: '%env(APP_DEFAULT_EMAIL_FROM)%' default_email_to: '%env(APP_DEFAULT_EMAIL_TO)%' + assignment_mailing_reply_to: '%env(APP_ASSIGNMENT_MAILING_REPLY_TO)%' # Per deployment and not per environment: staging and production run the same compiled # environment and differ only in their .env.local. The csv processor turns an unset @@ -204,6 +205,7 @@ services: $seasonTaskDeadlineOffset: '%season_task_deadline_offset%' $autoAssignmentJobProfiles: '%auto_assignment_job_profiles%' $autoAssignmentFees: '%auto_assignment_fees%' + $assignmentMailingReplyTo: '%assignment_mailing_reply_to%' # Tagged by interface rather than listed by hand: order between collectors is # irrelevant, so the only thing an explicit list could add here is the chance to diff --git a/src/Message/SendTeamerMailing.php b/src/Message/SendTeamerMailing.php index d06d3b1..cef19a0 100644 --- a/src/Message/SendTeamerMailing.php +++ b/src/Message/SendTeamerMailing.php @@ -17,8 +17,8 @@ use App\Model\TeamerMailingRecipientsDto; * finally sent, so a queued mailing never carries their content. * * With $listColleagues every mail ends with the names and addresses of the other recipients, - * taken from the same snapshot. $replyTo is the sender's address, kept here because the worker - * has no logged-in user to ask. + * taken from the same snapshot. $replyTo is decided when the mailing is queued, so a deploy + * that changes it does not reroute answers to a mailing already on its way. */ class SendTeamerMailing { diff --git a/src/Service/Teamer/AssignmentMailingService.php b/src/Service/Teamer/AssignmentMailingService.php index 72e0a33..7108a5b 100644 --- a/src/Service/Teamer/AssignmentMailingService.php +++ b/src/Service/Teamer/AssignmentMailingService.php @@ -26,6 +26,7 @@ class AssignmentMailingService private readonly EntityManagerInterface $entityManager, private readonly MessageBusInterface $messageBus, private readonly LoggerInterface $logger, + private readonly string $assignmentMailingReplyTo, ) { } @@ -123,8 +124,8 @@ class AssignmentMailingService $recipients, $this->attachmentHandler->toMessageAttachments($attachments), listColleagues: true, - // answers go to whoever wrote the mailing, not to the app's sender address - replyTo: $sender->getEmail() + // answers go to the travel management inbox, not to the app's sender address + replyTo: $this->assignmentMailingReplyTo )); $this->logger->info('Send assignment mailing', [ diff --git a/tests/Controller/Administrative/AssignmentMailing/AssignmentMailingControllerTest.php b/tests/Controller/Administrative/AssignmentMailing/AssignmentMailingControllerTest.php index c651ec7..43a3824 100644 --- a/tests/Controller/Administrative/AssignmentMailing/AssignmentMailingControllerTest.php +++ b/tests/Controller/Administrative/AssignmentMailing/AssignmentMailingControllerTest.php @@ -38,8 +38,6 @@ class AssignmentMailingControllerTest extends WebTestCase private JobProfile $jobProfile; - private User $sender; - protected function setUp(): void { $this->client = static::createClient(server: ['HTTPS' => true]); @@ -220,8 +218,8 @@ class AssignmentMailingControllerTest extends WebTestCase $this->assertSame('/administrative/assignment', $this->client->getResponse()->headers->get('HX-Redirect')); $this->assertEmailCount(1); $this->assertSame('Hallo Anna', trim((new Crawler($this->getMailerMessage()->getHtmlBody()))->filter('p')->first()->text())); - // answers reach the manager who sent it - $this->assertSame($this->sender->getEmail(), $this->getMailerMessage()->getReplyTo()[0]->getAddress()); + // answers reach the travel management inbox, not the manager who sent it + $this->assertSame('reisemanagement@ep-reisen.de', $this->getMailerMessage()->getReplyTo()[0]->getAddress()); // alone in the mailing, so nobody to list $this->assertStringNotContainsString('Deine Kolleg:innen', (string) $this->getMailerMessage()->getHtmlBody()); @@ -399,7 +397,6 @@ class AssignmentMailingControllerTest extends WebTestCase $this->entityManager->flush(); $this->client->loginUser($user); - $this->sender = $user; } private function assignment(string $hotel): Assignment