feat(kobo-sync): add user scoped 2 way kobo sync (#2452)

* fix(kobo-sync): Kobo reading state sync by returning the device expected shape and improve management with new DTOs and timestamp normalization

- Introduced `KoboReadingStateList` and `KoboReadingStateRequest` DTOs for improved handling of reading states.
- Updated `KoboController` to utilize the new DTOs and log request bodies.
- Enhanced `KoboReadingStateService` to normalize timestamps during reading state updates and merges.
- Adjusted repository queries to include user ID for better data integrity.
- Updated tests to reflect changes in DTOs and repository interactions.

* feat(kobo-sync): Enhance Kobo reading state management with user ID integration

* feat(kobo-sync): Add JSON annotations to KoboReadingStateList for improved serialization

* refactor(kobo-sync): Update repository and service methods to enhance reading state retrieval logic

- Replaced the existing method for fetching reading states with a new query that orders results by priority and timestamps.
- Updated service classes to utilize the new repository method for improved data handling.
- Adjusted unit tests to reflect changes in repository interactions.

* Enhance KoboReadingStateService and add database migration for user_id

- Added a new column `user_id` to the `kobo_reading_state` table with a foreign key constraint referencing the `users` table.
- Updated the `KoboReadingStateService` class by adding a new method to check for blank values, improving code readability and maintainability.
This commit is contained in:
Ben Szabo
2026-02-02 10:27:58 -07:00
committed by GitHub
parent cb5f703c7e
commit a77cecdf21
11 changed files with 478 additions and 52 deletions
@@ -0,0 +1,15 @@
ALTER TABLE kobo_reading_state
ADD COLUMN IF NOT EXISTS user_id BIGINT NULL;
ALTER TABLE kobo_reading_state
ADD CONSTRAINT fk_kobo_reading_state_user
FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE;
ALTER TABLE kobo_reading_state
DROP INDEX IF EXISTS entitlement_id;
ALTER TABLE kobo_reading_state
ADD UNIQUE INDEX uq_kobo_reading_state_user_entitlement (user_id, entitlement_id);
CREATE INDEX IF NOT EXISTS idx_kobo_reading_state_entitlement_id
ON kobo_reading_state (entitlement_id);