Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
21 changes: 16 additions & 5 deletions modules/os2forms_forloeb/src/MaestroHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -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,
Expand All @@ -378,6 +381,7 @@ private function sendNotificationDigitalPost(
string $actionLabel,
WebformSubmissionInterface $submission,
string $notificationType,
string $senderLabel,
): void {
try {
$document = new Document(
Expand All @@ -386,7 +390,6 @@ private function sendNotificationDigitalPost(
$subject . '.pdf'
);

$senderLabel = $subject;
$messageLabel = $subject;

$recipientLookupResult = $this->digitalPostHelper->lookupRecipient($recipient);
Expand Down Expand Up @@ -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
Expand All @@ -453,13 +456,20 @@ private function sendNotificationDigitalPost(
* - subject
* - taskUrl (for digital post)
* - actionLabel (for digital post)
* - senderLabel (for digital post)
*
* @see self::renderHtml()
*/
public function renderNotification(WebformSubmissionInterface $submission, string $handlerId, string $notificationType, array $templateTask, int $maestroQueueID, ?string $contentType = NULL): array {
$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.
Expand Down Expand Up @@ -558,6 +568,7 @@ public function renderNotification(WebformSubmissionInterface $submission, strin
'subject' => $subject,
'taskUrl' => $taskUrl,
'actionLabel' => $actionLabel,
'senderLabel' => $senderLabel,
];
}

Expand Down
Loading