wire-ios
wire-ios copied to clipboard
refactor: mls group verification in `ZMUserSession` [WPB-9149]
|
|
Motivation
The ZMUserSession's initialiser takes about 25 arguments. They can be categorised in two:
- primary dependencies: foundational services, caches etc.. Ideally they should not use other dependencies.
- secondary dependencies: derived objects that can be initialised by the primary dependencies.
The ObserveMLSGroupVerificationStatusUseCase belongs to category 2 and thus should not be passed to the initialiser of ZMUserSession to avoid a infinite growing of responsibilities.
The second point was, that the use case has a state. Therefore it was required to retain the whole use case and keep a task reference alive, again a responsibility of ZMUserSession until now. This is implicit and cannot be easily understand from the outer scope.
Refactoring
- While working on it, I figured out that the logic broke into several smaller files, that kind of belong together, and overlapped in some points, logs etc.:
ObserveMLSGroupVerificationStatusUseCaseMLSConversationVerificationStatusUpdaterUpdateMLSGroupVerificationStatusUseCase
ObserveMLSGroupVerificationStatusUseCase and MLSConversationVerificationStatusUpdater got merged into MLSGroupVerification. Extract extension to user session. Simplify mocking and unit tests.
- Extract
CertificateRevocationListsas extension to user session.
Review
[!NOTE] Start your review in
ZMUserSession.swiftto see the benefit there.
Maybe it's also helpful to checkout the whole branch and read classes in code.
Testing
- Simple test: breakpoints, run the app and login
- For the whole ticket we need to test the MLS group verification with @KaterinaWire and QA.
Checklist
- [x] Title contains a reference JIRA issue number like
[WPB-XXX]. - [x] Description is filled and free of optional paragraphs.
- [x] Adds/updates automated tests.
Test Results
ββββ5 filesββββ894 suitesβββ24m 10s :stopwatch: 7β270 testsβ7β270 :white_check_mark:β0 :zzz:β0 :x: 7β278 runsββ7β278 :white_check_mark:β0 :zzz:β0 :x:
Results for commit 4da25044.
:recycle: This comment has been updated with latest results.
Datadog Report
Branch report: refactor/zmusersession-observeMLSGroupVerificationStatusUseCase
Commit report: d03f80d
Test service: wire-ios-mono
:white_check_mark: 0 Failed, 7270 Passed, 0 Skipped, 2m 59.94s Total Time