wultra / powerauth-push-server

PowerAuth Push Server repository
Apache License 2.0
25 stars 12 forks source link

Fix #742: Separate service layer from PushDeviceController #766

Closed jnpsk closed 8 months ago

jnpsk commented 8 months ago

Fix #742 by extracting validation and business logic from the PushDeviceController.
There are two new service classes. PushDeviceService is called right away by controller, it handles validation or fetching credential entity if needed. This service class uses DeviceRegistrationService which finally communicates with the devices repository. The intention of this split is to reduce the complexity and to benefit from @Retryable annotation.

Except for the DeviceRegistrationService#updateStatus no significant changes were applied (just moved). The updateStatus were modified to increase readability of the code. All the refactored code is now covered with tests.

The default value for retry attempts was decreased from 3 to 2, as that number is sufficient by default.

There was also a bug regarding /push/device/create/multi endpoint - when an activationId was repeated in single request, the server returned a constraint violation error. This is now fixed by distinct filter in DeviceRegistrationService#createOrUpdateDevices.