Commit Graph

14 Commits

Author SHA1 Message Date
Jorge Martin Espinosa
721add707c Simplify push notification flow by using locally stored values for pending pushes (#6258)
* Create `PushRequest` in push history DB: this will be used to store requests for push notifications, either pending or completed ones.

* Rename `WorkManagerRequest` to `WorkManagerRequestBuilder`: make its `build` method return a list of `WorkManagerRequestWrapper`, which can be used to enqueue normal or unique workers.

* Rename `PerformDatabaseVacuumRequestBuilder` and adapt it to the new API.

* Adjust other components using `WorkManagerRequest`.

* Replace `SyncNotificationWorkManagerRequestBuilder` with `SyncPendingNotificationsRequestBuilder` and `FetchNotificationsWorker` with `FetchPendingNotificationsWorker`: this new pair of request builder and worker allow enqueuing requests for a session id and, once the worker runs, retrieve all the pending request data and use it to fetch the associated events. This simplifies quite a bit how this data had to be passed or grouped, since it's no longer necessary to do so

* Add new methods to `PushHistoryService` to modify the `PushDatabase`:

- insertOrUpdatePushRequest
- insertOrUpdatePushRequests
- getPendingPushRequests
- removeOldPushRequests

* Make `PushHandler` just handle incoming pushes: those will be inserted into the pending push request table in DB, then handled by the new worker. Once the process finished, a new `NotificationResultProcessor` will handle the results and what needs to be done with them (call ringing, displaying notifications, etc.)

* Add `requestType` optional parameter to `WorkManagerScheduler.cancel` so we can decide to only cancel some kinds of requests.

* Add migration to remove existing work manager requests for fetching notifications, since the previous worker class no longer exists.
2026-03-03 15:14:36 +00:00
Jorge Martín
1e52e1139f Tweak the DefaultWorkManagerScheduler.hasPendingWork logic 2025-12-10 15:22:16 +01:00
Jorge Martín
d78e28be5e Make sure we schedule the vacuum task only if there isn't an existing one 2025-12-10 15:22:16 +01:00
Jorge Martín
6887ca06d7 Fix lint issues 2025-12-10 15:22:16 +01:00
Jorge Martín
482d7e0648 Add a periodic DB vacuuming task 2025-12-10 15:22:16 +01:00
Jorge Martín
f15a236c10 Make DefaultWorkManagerScheduler a singleton sin it now has an observer that should be a singleton 2025-12-05 17:42:57 +01:00
Jorge Martín
7eae3a16ae Use SessionObserver instead of SessionStore to observe sessions 2025-12-05 17:42:57 +01:00
Jorge Martín
221e18d139 Test DefaultWorkManagerScheduler 2025-12-05 17:42:57 +01:00
Benoit Marty
0355c0bda9 Improve code again 2025-11-19 18:28:00 +01:00
Benoit Marty
e0c829d887 First attempt 2025-11-19 16:56:01 +01:00
Benoit Marty
1292da2a72 Copyright: Add Element Creations Ltd. copyright 2025-11-10 11:05:05 +01:00
Benoit Marty
b748fcc631 Copyright: Add final period 2025-11-10 10:13:41 +01:00
Benoit Marty
826cacf209 Remove @Inject, not necessary anymore when class is annotated with @ContributesBinding 2025-10-22 18:52:37 +02:00
Jorge Martin Espinosa
597c9b473a Sync notifications using WorkManager (#5545)
* Initial implementation of notification sync using `WorkManager`

* Use custom `MetroWorkerFactory` to allow assisted injection in WorkManager Workers

* Add tests for `FetchNotificationWorker`. Create `FakeNotificationResolverQueue` to help testing.

* Add more tests, fix Konsist checks

* Add tests for `SyncNotificationWorkManagerRequest`

* Simplify `FakeNotificationResolverQueue`
2025-10-17 09:51:27 +00:00