diff --git a/CHANGELOG.md b/CHANGELOG.md index 880c6b7..2f94571 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,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. ## [4.1.0] 2025-06-03 diff --git a/modules/os2forms_forloeb/src/MaestroHelper.php b/modules/os2forms_forloeb/src/MaestroHelper.php index d2dd0c5..034649c 100644 --- a/modules/os2forms_forloeb/src/MaestroHelper.php +++ b/modules/os2forms_forloeb/src/MaestroHelper.php @@ -250,13 +250,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); } } } @@ -368,7 +369,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, @@ -378,6 +381,7 @@ private function sendNotificationDigitalPost( string $actionLabel, WebformSubmissionInterface $submission, string $notificationType, + string $senderLabel, ): void { try { $document = new Document( @@ -386,7 +390,6 @@ private function sendNotificationDigitalPost( $subject . '.pdf' ); - $senderLabel = $subject; $messageLabel = $subject; $recipientLookupResult = $this->digitalPostHelper->lookupRecipient($recipient); @@ -436,13 +439,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 @@ -453,6 +456,7 @@ private function sendNotificationDigitalPost( * - subject * - taskUrl (for digital post) * - actionLabel (for digital post) + * - senderLabel (for digital post) * * @see self::renderHtml() */ @@ -460,6 +464,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. @@ -558,6 +568,7 @@ public function renderNotification(WebformSubmissionInterface $submission, strin 'subject' => $subject, 'taskUrl' => $taskUrl, 'actionLabel' => $actionLabel, + 'senderLabel' => $senderLabel, ]; }