digdir / dialogporten

Dialogporten - common API and and metadata state store for digital dialogs
https://digdir.github.io/dialogporten/
MIT License
0 stars 3 forks source link

Add endpoint to activity log to allow for notification condition checks #859

Open elsand opened 2 weeks ago

elsand commented 2 weeks ago

Introduction

Dialogporten should provide an endpoint for the notification endpoint to use in order to determine whether or not a notidication should be provided

Description

Notification orders can be decorated with a "conditionUrl", which the notification component will request before handling it. Based upon the response given, the notification order is either ignored (closed) or provided.

This relies on the functionality described in https://github.com/Altinn/altinn-notifications/issues/547

Implementation

The final design of this feature is still in progress. The following assumptions are made:

We need to consider if we want to make this generic or something bespoke for the notification component. An idea could be a simple URL query based DSL for these conditions, something akin to:

https://dialogporten.no/api/v1/serviceowner/{{dialogGuid}}/activitylog/?condition=notexists&type=transmissionOpened&relatedTransmissionId={{transmissionId}}

This should be parsed as "return true if there is no entries in the activity log of {{dialogGuid}} having the type "transmissionOpened" and the relatedTransmissionId set to {{transmissionId}}".

"condition" and "type" should be mandatory, and type matching any of the valid activityLog types. "condition" should for now only be "exists" and "notexists". "relatedTransmissionId" should be optional.

### Tasks
- [ ] Add authorization policy for notification to use
- [ ] Add query parameters to activitylog endpoint
- [ ] Add validation
- [ ] Add condition DTO
- [ ] Add notexists/exists logic
- [ ] Prepare documentation (if relevant - either update working document, or add a new file in `docs`)
- [ ] Add e2e-test (if relevant)
### Threat modelling
- [ ] Does this change introduce any potential security issues?

Acceptance criteria

GIVEN ... WHEN .... THEN ...

GIVEN ... WHEN .... THEN ...