diff --git a/CHANGELOG.md b/CHANGELOG.md index c029edf..412754b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,8 @@ before starting to add changes. Use example [placed in the end of the page](#exa Remove unused and abandoned package `webmozart/path-util`. - [PR-167](https://github.com/OS2Forms/os2forms/pull/167) Adding os2forms_digital_signature module +- [PR-222](https://github.com/OS2Forms/os2forms/pull/222) + Correctly sets sender label on Maestro digital post notifications. - [OS-199] Remove modules that are not used and not covered by central maintenance from OS2forms ## [4.1.0] 2025-06-03 diff --git a/modules/os2forms_forloeb/src/MaestroHelper.php b/modules/os2forms_forloeb/src/MaestroHelper.php index 0beea88..44df39c 100644 --- a/modules/os2forms_forloeb/src/MaestroHelper.php +++ b/modules/os2forms_forloeb/src/MaestroHelper.php @@ -251,13 +251,14 @@ private function sendNotification( 'subject' => $subject, 'taskUrl' => $taskUrl, 'actionLabel' => $actionLabel, + 'senderLabel' => $senderLabel, ] = $this->renderNotification($submission, $handler->getHandlerId(), $notificationType, $templateTask, $maestroQueueID); if ('email' === $contentType) { $this->sendNotificationEmail($recipient, $subject, $content, $submission, $notificationType); } else { - $this->sendNotificationDigitalPost($recipient, $subject, $content, $taskUrl, $actionLabel, $submission, $notificationType); + $this->sendNotificationDigitalPost($recipient, $subject, $content, $taskUrl, $actionLabel, $submission, $notificationType, $senderLabel); } } } @@ -369,7 +370,9 @@ private function sendNotificationEmail( * @param \Drupal\webform\WebformSubmissionInterface $submission * The webform submission. * @param string $notificationType - * The notification type (one of the NOTIFICATION_* constannts). + * The notification type (one of the NOTIFICATION_* constants). + * @param string $senderLabel + * The sender label. */ private function sendNotificationDigitalPost( string $recipient, @@ -379,6 +382,7 @@ private function sendNotificationDigitalPost( string $actionLabel, WebformSubmissionInterface $submission, string $notificationType, + string $senderLabel, ): void { try { $document = new Document( @@ -387,7 +391,6 @@ private function sendNotificationDigitalPost( $subject . '.pdf' ); - $senderLabel = $subject; $messageLabel = $subject; $recipientLookupResult = $this->digitalPostHelper->lookupRecipient($recipient); @@ -437,13 +440,13 @@ private function sendNotificationDigitalPost( * @param string $handlerId * The handler ID. * @param string $notificationType - * The notification type (one of the NOTIFICATION_* constannts). + * The notification type (one of the NOTIFICATION_* constants). * @param array $templateTask * The Maestro template task. * @param int $maestroQueueID * The Maestro queue ID. * @param string|null $contentType - * Optional content type. If not set the content type will be compoted based + * Optional content type. If not set the content type will be computed based * on the recipient. * * @return array @@ -454,6 +457,7 @@ private function sendNotificationDigitalPost( * - subject * - taskUrl (for digital post) * - actionLabel (for digital post) + * - senderLabel (for digital post) * * @see self::renderHtml() */ @@ -461,6 +465,12 @@ public function renderNotification(WebformSubmissionInterface $submission, strin $handler = $submission->getWebform()->getHandler($handlerId); $settings = $handler->getSettings(); + $senderLabel = $settings[MaestroNotificationHandler::NOTIFICATION][MaestroNotificationHandler::SENDER_LABEL] ?? NULL; + + if (NULL === $senderLabel) { + throw new RuntimeException(sprintf('Cannot get setting for Maestro notification: %s', MaestroNotificationHandler::SENDER_LABEL)); + } + $data = $submission->getData(); $recipientElement = $settings[MaestroNotificationHandler::NOTIFICATION][MaestroNotificationHandler::RECIPIENT_ELEMENT] ?? NULL; // Handle os2forms_person_lookup element. @@ -559,6 +569,7 @@ public function renderNotification(WebformSubmissionInterface $submission, strin 'subject' => $subject, 'taskUrl' => $taskUrl, 'actionLabel' => $actionLabel, + 'senderLabel' => $senderLabel, ]; }