Skip to content

Commit

Permalink
Merge pull request #383 from itk-dev/release/1.5.3
Browse files Browse the repository at this point in the history
Release 1.5.3
  • Loading branch information
rimi-itk authored Dec 19, 2023
2 parents 965c779 + b6c69d9 commit 325cc44
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 41 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ about writing changes to this log.

## [Unreleased]

## [1.5.3] - 2023-12-19

- [PR-377](https://github.com/itk-dev/naevnssekretariatet/pull/377)
Improved `tvist1:digital-post-envelope:list` command and added Digital post
debug command.

## [1.5.2]

- [PR-378](https://github.com/itk-dev/naevnssekretariatet/pull/378)
Expand Down Expand Up @@ -292,7 +298,8 @@ Fixed error in unescaped characters in filename
- [TVIST1-604](https://jira.itkdev.dk/browse/TVIST1-604):
Resolved issue regarding time formats.

[Unreleased]: https://github.com/itk-dev/naevnssekretariatet/compare/1.5.2...HEAD
[Unreleased]: https://github.com/itk-dev/naevnssekretariatet/compare/1.5.3...HEAD
[1.5.3]: https://github.com/itk-dev/naevnssekretariatet/compare/1.5.2...1.5.3
[1.5.2]: https://github.com/itk-dev/naevnssekretariatet/compare/1.5.1...1.5.2
[1.5.1]: https://github.com/itk-dev/naevnssekretariatet/compare/1.5.0...1.5.1
[1.5.0]: https://github.com/itk-dev/naevnssekretariatet/compare/1.4.1...1.5.0
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
"gedmo/doctrine-extensions": "^3.0",
"itk-dev/azure-key-vault-php": "^1.0",
"itk-dev/beskedfordeler-symfony": "^1.0",
"itk-dev/datafordeler-php-client": "dev-develop",
"itk-dev/openid-connect-bundle": "dev-develop",
"itk-dev/serviceplatformen": "dev-feature/guzzle7-adapter",
"itk-dev/datafordeler-php-client": "^1.0",
"itk-dev/openid-connect-bundle": "^2.0",
"itk-dev/serviceplatformen": "dev-feature/tvist1",
"knplabs/knp-paginator-bundle": "^5.6",
"league/oauth2-client": "^2.6",
"lexik/form-filter-bundle": "^7.0",
Expand Down
43 changes: 20 additions & 23 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions src/Command/DigitalPostDebugCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

namespace App\Command;

use App\Service\SF1601\DigitalPoster;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand(
name: 'tvist1:digital-post:debug',
description: 'Add a short description for your command',
)]
class DigitalPostDebugCommand extends Command
{
public function __construct(
readonly private DigitalPoster $digitalPoster
) {
parent::__construct(null);
}

protected function configure(): void
{
$this->addArgument('action', InputArgument::REQUIRED, 'The action');
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
$action = $input->getArgument('action');

switch ($action) {
case 'getSAMLToken':
case 'fetchSAMLToken':
$sf1601 = $this->invoke($this->digitalPoster, 'getSF1601');
$entityId = 'http://entityid.kombit.dk/service/kombipostafsend/1';
$samlToken = $this->invoke($sf1601, $action, [$entityId]);

$output->write(json_encode($samlToken));

return Command::SUCCESS;
}
}

/**
* Invoke method on an object.
*/
private function invoke(object $object, string $method, array $args = []): mixed
{
$method = new \ReflectionMethod($object, $method);
$method->setAccessible(true);

return $method->invoke($object, ...$args);
}
}
11 changes: 10 additions & 1 deletion src/Command/DigitalPostEnvelopeListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ protected function configure()
{
$this
->addOption('status', null, InputOption::VALUE_REQUIRED, 'Show only envelopes with this status')
->addOption('digital-post-subject', null, InputOption::VALUE_REQUIRED, 'Show only envelopes with subject matching this LIKE expression')
->addOption('digital-post-id', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Show only envelopes with the digital post id')
->addOption('digital-post-subject', null, InputOption::VALUE_REQUIRED, 'Show only envelopes with digital post subjects matching this LIKE expression')
->addOption('max-results', null, InputOption::VALUE_REQUIRED, 'Show at most this many envelopes', 10)
->addOption('id', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Envelope id')
->addOption('message-uuid', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Messaged uuid')
Expand Down Expand Up @@ -134,6 +135,14 @@ private function findEnvelopes(InputInterface $input): array
->setParameter('status', $status)
;
}
if ($ids = $input->getOption('digital-post-id')) {
$ids = array_map(static fn (string $id) => Uuid::fromString($id)->toBinary(), $ids);
$qb
->join('e.digitalPost', 'p')
->andWhere('p.id IN (:digital_post_ids)')
->setParameter('digital_post_ids', $ids)
;
}
if ($subject = $input->getOption('digital-post-subject')) {
$qb
->join('e.digitalPost', 'p')
Expand Down
29 changes: 16 additions & 13 deletions src/Service/SF1601/DigitalPoster.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,7 @@ public function __construct(private CertificateLocatorHelper $certificateLocator

public function canReceive(string $type, string $identifier): ?bool
{
$options = $this->options['sf1601']
+ [
'certificate_locator' => $this->certificateLocatorHelper->getCertificateLocator(),
];
unset($options[ForsendelseHelper::FORSENDELSES_TYPE_IDENTIFIKATOR]);
$service = new SF1601($options);

$service = $this->getSF1601();
$transactionId = Serializer::createUuid();

return $service->postForespoerg($transactionId, $type, $identifier);
Expand Down Expand Up @@ -80,12 +74,7 @@ public function sendDigitalPost(DigitalPost $digitalPost, DigitalPost\Recipient
];
$forsendelse = $this->forsendelseHelper->createForsendelse($digitalPost, $recipient, $forsendelseOptions);

$options = $this->options['sf1601']
+ [
'certificate_locator' => $this->certificateLocatorHelper->getCertificateLocator(),
];
unset($options[ForsendelseHelper::FORSENDELSES_TYPE_IDENTIFIKATOR]);
$service = new SF1601($options);
$service = $this->getSF1601();
$transactionId = Serializer::createUuid();
$response = $service->kombiPostAfsend($transactionId, SF1601::TYPE_AUTOMATISK_VALG, $meMoMessage, $forsendelse);

Expand Down Expand Up @@ -154,6 +143,20 @@ public function sendDigitalPost(DigitalPost $digitalPost, DigitalPost\Recipient
}
}

/**
* Get SF1601 instance.
*/
private function getSF1601(): SF1601
{
$options = $this->options['sf1601']
+ [
'certificate_locator' => $this->certificateLocatorHelper->getCertificateLocator(),
];
unset($options[ForsendelseHelper::FORSENDELSES_TYPE_IDENTIFIKATOR]);

return new SF1601($options);
}

private function resolveOptions(array $options): array
{
return (new OptionsResolver())
Expand Down

0 comments on commit 325cc44

Please sign in to comment.