Skip to content

Commit

Permalink
Audit logged digital post
Browse files Browse the repository at this point in the history
  • Loading branch information
jekuaitk committed Nov 22, 2024
1 parent 82b4e4a commit ddd0742
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ dependencies:
- 'os2web_datalookup:os2web_datalookup'
- 'webform:webform'
- 'webform:webform_submission_log'
- 'os2web:os2web_audit'

configure: os2forms_digital_post.admin.settings
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ services:
- "@Drupal\\os2forms_digital_post\\Helper\\BeskedfordelerHelper"
- "@logger.channel.os2forms_digital_post"
- "@logger.channel.os2forms_digital_post_submission"
- "@os2web_audit.logger"

Drupal\os2forms_digital_post\Helper\WebformHelperSF1601:
arguments:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use DigitalPost\MeMo\Message;
use Drupal\Core\Logger\LoggerChannelInterface;
use Drupal\os2forms_digital_post\Exception\RuntimeException;
use Drupal\os2web_audit\Service\Logger;
use Drupal\os2web_datalookup\LookupResult\CompanyLookupResult;
use Drupal\os2web_datalookup\LookupResult\CprLookupResult;
use Drupal\os2web_datalookup\Plugin\DataLookupManager;
Expand Down Expand Up @@ -35,6 +36,7 @@ public function __construct(
private readonly BeskedfordelerHelper $beskedfordelerHelper,
private readonly LoggerChannelInterface $logger,
private readonly LoggerChannelInterface $submissionLogger,
private readonly Logger $auditLogger,
) {
}

Expand Down Expand Up @@ -64,13 +66,19 @@ public function sendDigitalPost(string $type, Message $message, ?ForsendelseI $f
];
$service = new SF1601($options);
$transactionId = Serializer::createUuid();

$response = $service->kombiPostAfsend($transactionId, $type, $message, $forsendelse);

$content = (string) $response->getContent();
if (NULL !== $submission) {
$this->beskedfordelerHelper->createMessage($submission->id(), $message, $content);
}

// RecipientID should be the same in Message and Forsendelse,
// so fetch it from Message as it is always set.
$msg = sprintf('Sent digital post of type %s to %s', $type, $message->getMessageHeader()->getRecipient()->getRecipientID());
$this->auditLogger->info('DigitalPost', $msg);

return [$response, $service->getLastKombiMeMoMessage()];
}

Expand Down

0 comments on commit ddd0742

Please sign in to comment.