Skip to content

Commit

Permalink
Added Digital post module
Browse files Browse the repository at this point in the history
  • Loading branch information
rimi-itk committed Oct 2, 2023
1 parent 14deaec commit 6c167d1
Show file tree
Hide file tree
Showing 46 changed files with 3,363 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ jobs:
- name: Yarn install
uses: actions/setup-node@v2
with:
node-version: '18'
node-version: '20'
- run: yarn install
- name: markdownlint
run: yarn coding-standards-check/markdownlint
8 changes: 7 additions & 1 deletion .markdownlintrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
{
// @see https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.jsonc
// MD013/line-length - Line length
// https://github.com/DavidAnson/markdownlint/blob/main/doc/md013.md
"MD013": {
// Exclude code blocks
"code_blocks": false
},

// Prevent complaining on duplicated headings in CHANGELOG.md
// https://github.com/DavidAnson/markdownlint/blob/main/doc/md024.md
"MD024": {
"siblings_only": true
}
}

Expand Down
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,20 @@ docker run --rm --volume ${PWD}:/app --workdir /app itkdev/php8.1-fpm composer c
### Markdown

```sh
docker run --rm --volume ${PWD}:/app --workdir /app node:18 yarn install
docker run --rm --volume ${PWD}:/app --workdir /app node:18 yarn coding-standards-check/markdownlint
docker run --rm --volume ${PWD}:/app --workdir /app node:20 yarn install
docker run --rm --volume ${PWD}:/app --workdir /app node:20 yarn coding-standards-check/markdownlint

# Fix (some) coding standards issues.
docker run --rm --volume ${PWD}:/app --workdir /app node:18 yarn coding-standards-apply/markdownlint
docker run --rm --volume ${PWD}:/app --workdir /app node:20 yarn coding-standards-apply/markdownlint
```

## Code analysis

We use [PHPStan](https://phpstan.org/) for static code analysis.

Running statis code analysis on a standalone Drupal module is a bit tricky, so
we use a helper script to run the analysis:

```sh
./scripts/code-analysis
```
30 changes: 26 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
}
},
"require": {
"php": "^8.1",
"ext-dom": "*",
"ext-soap": "*",
"cweagans/composer-patches": "^1.6.5",
"dompdf/dompdf": "^2.0",
"drupal/admin_toolbar": "^3.0",
Expand Down Expand Up @@ -68,11 +71,17 @@
"drupal/webform_validation": "^2.0",
"drupal/webform_views": "^5.0@alpha",
"drupal/workflow_participants": "^2.4",
"os2web/os2web_datalookup": "^1.0",
"http-interop/http-factory-guzzle": "^1.0.0",
"itk-dev/beskedfordeler-drupal": "^1.0",
"itk-dev/serviceplatformen": "dev-feature/guzzle6-adapter as 1.5",
"os2web/os2web_datalookup": "^1.5",
"os2web/os2web_nemlogin": "^1.0",
"php-http/guzzle6-adapter": "^2.0",
"phpoffice/phpword": "^0.18.2",
"symfony/options-resolver": "^5.4 || ^6.0",
"tecnickcom/tcpdf": "~6",
"webmozart/path-util": "^2.3",
"wsdltophp/packagebase": "^5.0",
"zaporylie/composer-drupal-optimizations": "^1.2"
},
"suggest": {
Expand All @@ -81,7 +90,12 @@
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1",
"drupal/coder": "^8.3",
"drupal/maillog": "^1.0"
"drupal/maillog": "^1.0",
"mglaman/phpstan-drupal": "^1.1",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan-deprecation-rules": "^1.1",
"phpunit/phpunit": "^9.5",
"wsdltophp/packagegenerator": "^4.0"
},
"extra" : {
"composer-exit-on-patch-failure": false,
Expand All @@ -105,6 +119,12 @@
}
},
"scripts": {
"code-analysis/phpstan": [
"phpstan analyse"
],
"code-analysis": [
"@code-analysis/phpstan"
],
"coding-standards-check/phpcs": [
"phpcs --standard=phpcs.xml.dist"
],
Expand All @@ -121,9 +141,11 @@
"config": {
"sort-packages": true,
"allow-plugins": {
"simplesamlphp/composer-module-installer": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"cweagans/composer-patches": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"phpstan/extension-installer": true,
"simplesamlphp/composer-module-installer": true,
"vaimo/composer-patches": true,
"zaporylie/composer-drupal-optimizations": true
}
}
Expand Down
6 changes: 6 additions & 0 deletions modules/os2forms_digital_post/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
vendor
composer.lock
node_modules
yarn.lock

src/Controller/SF1601Controller.php.log
117 changes: 117 additions & 0 deletions modules/os2forms_digital_post/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<!-- markdownlint-disable MD024 -->
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic
Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [3.0.1]

### Fixed

- Fixed issue with wrong service being injected.
[PR-50](https://github.com/itk-dev/os2forms_digital_post/pull/50)

## [3.0.0]

### Added

- Added API for sending digital post
[PR-40](https://github.com/itk-dev/os2forms_digital_post/pull/40)

### Changed

- Changed dependency on CPR and CVR lookup modules. Handled physical post
(“forsendelse”)
[PR-37](https://github.com/itk-dev/os2forms_digital_post/pull/37)

### Removed

- Removed support for [SF-1600](https://digitaliseringskataloget.dk/integration/sf1600).

## [2.0.2]

### Added

- Added the `CPR / Navn validering` element to allowed recipient element names
[PR-43](https://github.com/itk-dev/os2forms_digital_post/pull/43)

## Changed

- Changed composer name to `os2forms/os2forms_digital_post`
[PR-47](https://github.com/itk-dev/os2forms_digital_post/pull/47)

## [2.0.1]

## Changed

- Updated allowed attachment elements to contain `os2forms_attachment`

## [2.0.0]

### Changed

- Updates `dompdf/dompdf` requirement to `^2.0`
[PR-41](https://github.com/itk-dev/os2forms_digital_post/pull/41)

## [1.2.3]

### Changed

- Updated recipient element names
[PR-38](https://github.com/itk-dev/os2forms_digital_post/pull/38)

## [1.2.2]

### Added

- Added creation of Beskedfordeler table.

## [1.2.0]

### Added

- Added handling of CVR recipients.
- Added handling of Beskedfordeler messages.

### Changed

- Update dompdf dependency.

## [1.1.2]

- Updated logging.
- Fixed setting person id

## [1.1.1]

### Changed

- Remove CPR from exception
- Added more recipient field types
- Fixed error logging.

## [1.1.0]

### Added

- Added support for [SF1601 »
“KombiPostAfsend”](https://digitaliseringskataloget.dk/integration/sf1601).
- Added GitHub Actions for coding standards checks and code analysis.

[Unreleased]: https://github.com/itk-dev/os2forms_digital_post/compare/3.0.1...HEAD
[3.0.1]: https://github.com/itk-dev/os2forms_digital_post/compare/3.0.0...3.0.1
[3.0.0]: https://github.com/itk-dev/os2forms_digital_post/compare/2.0.2...3.0.0
[2.0.2]: https://github.com/itk-dev/os2forms_digital_post/compare/2.0.1...2.0.2
[2.0.1]: https://github.com/itk-dev/os2forms_digital_post/compare/2.0.0...2.0.1
[2.0.0]: https://github.com/itk-dev/os2forms_digital_post/compare/1.2.3...2.0.0
[1.2.3]: https://github.com/itk-dev/os2forms_digital_post/compare/1.2.2...1.2.3
[1.2.2]: https://github.com/itk-dev/os2forms_digital_post/compare/1.2.0...1.2.2
[1.2.0]: https://github.com/itk-dev/os2forms_digital_post/compare/1.1.2...1.2.0
[1.1.2]: https://github.com/itk-dev/os2forms_digital_post/compare/1.1.1...1.1.2
[1.1.1]: https://github.com/itk-dev/os2forms_digital_post/compare/1.1.0...1.1.1
[1.1.0]: https://github.com/itk-dev/os2forms_digital_post/compare/1.0.2...1.1.0
108 changes: 108 additions & 0 deletions modules/os2forms_digital_post/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# OS2Forms Digital Post

Send Digital Post to danish citizens from a webform.

This module uses the
[SF1601](https://digitaliseringskataloget.dk/integration/sf1601) service from
Serviceplatformen. Information and documentation can be obtained by following
that link.

## Usage

This module provides functionality for sending digital post to danish citizens.
A WebformHandler is provided that you can add to your webform, and if configured
it will send the submitted data as digital post.

## Beskedfordeler endpoint

This module provides an endpoint,
`/os2forms_digital_post/PostStatusBeskedModtag`, for
[PostStatusBeskedModtag](https://digitaliseringskataloget.dk/integration/sf1601)
to get information on how or why not a digital post has been delivered. See
“PostStatusBeskedHent” on
<https://digitaliseringskataloget.dk/integration/sf1601> for details.

## Installation

Require it with composer:

```shell
composer require "os2forms/os2forms_digital_post"
```

Enable it with drush:

```shell
drush pm:enable os2forms_digital_post
```

### Example forms

See [OS2Forms Digital Post
examples](modules/os2forms_digital_post_examples/README.md).

## Configuration

Go to `/admin/os2forms_digital_post/settings` to set up global settings for
digital post.

## Drush commands

```sh
drush --uri=$(itkdev-docker-compose url) os2forms_digital_post:digital-post:send --help

drush --uri=$(itkdev-docker-compose url) os2forms_digital_post:digital-post:memo-show --help
```

## Queue

Digital post is sent via jobs via an [Advanced
Queue](https://www.drupal.org/project/advancedqueue) called
`os2forms_digital_post`.

The queue is processed via [Drupal's cron
run](https://www.drupal.org/docs/administering-a-drupal-site/cron-automated-tasks/cron-automated-tasks-overview),
but you can manually process the queue with `drush` if you want to process it
more often than other Drupal cron jobs:

```sh
drush advancedqueue:queue:process os2forms_digital_post
```

List the queue (and all other queues) with

```sh
drush advancedqueue:queue:list
```

or go to `/admin/config/system/queues/jobs/os2forms_digital_post` for a
graphical overview of jobs in the queue.

<!-- markdownlint-enable MD013 -->
<!-- markdownlint-enable MD022 -->
<!-- markdownlint-enable MD025 -->
<!-- markdownlint-enable MD031 -->
<!-- markdownlint-enable MD032 -->
## Coding standards

All coding standards are checked with [GitHub
Actions](https://github.com/features/actions) when a pull request is made (cf.
<.github/workflows/pr.yaml>).

Check coding standards:

```sh
docker run --rm --interactive --tty --volume ${PWD}:/app itkdev/php8.1-fpm:latest composer install
docker run --rm --interactive --tty --volume ${PWD}:/app itkdev/php8.1-fpm:latest composer coding-standards-check

docker run --rm --interactive --tty --volume ${PWD}:/app node:18 yarn --cwd /app install
docker run --rm --interactive --tty --volume ${PWD}:/app node:18 yarn --cwd /app coding-standards-check
```

Apply coding standards:

```shell
docker run --rm --interactive --tty --volume ${PWD}:/app itkdev/php8.1-fpm:latest composer coding-standards-apply

docker run --rm --interactive --tty --volume ${PWD}:/app node:18 yarn --cwd /app coding-standards-apply
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
langcode: en
status: true
dependencies:
module:
- os2forms_digital_post
enforced:
module:
- os2forms_digital_post
id: os2forms_digital_post
label: 'OSForms digital post'
backend: database
backend_configuration:
lease_time: 300
processor: cron
processing_time: 90
locked: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# OS2Forms Digital Post examples

Examples for OS2Forms Digital Post.

## Installation

```sh
drush pm:enable os2forms_digital_post_examples
```

Go to `/admin/structure/webform?category=Example` to see the example forms.
Loading

0 comments on commit 6c167d1

Please sign in to comment.