feat: send replies to assignment mailings to the travel management inbox

This commit is contained in:
fromme committed 2026-11-12 12:37:35 +01:00
1 parent 74080b0488
commit 2c51ddf86f
5 files changed
+13 -9

No files matched your search

+4
View File
@@ -70,6 +70,10 @@ APP_BPN_CRM_ID_TEAMER=1070
APP_DEFAULT_EMAIL_FROM=[email protected]
APP_DEFAULT_EMAIL_TO=[email protected]
# 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=[email protected]
# 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
+2
View File
@@ -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
+2 -2
View File
@@ -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
{
@@ -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', [
@@ -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('[email protected]', $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