Significant refactor of notification encryption code
Summary:
This differential does two important things:
- Changes notification encryption API so that we must pass device tokens along with cookieIDs and encrypted notifications carry thos device token and cookieIDs. This enables us to use thos methods with ease without need to handle independent arrays
ordering which is a brittle design.
- It uses the ability to conditionally skip olm session database update. Previously we used to encrypt two notifications: with and without messageInfos. Then we decided which one is going to be delivered. As a result the client hand to keep skipped olm
key for the notif that wasn't delivered. Now it is ensured it is not happening.
Test Plan:
- Test that encrypted notifications/ rescinds and badge-only notifications work correctly.
- Ensure that each notification advances keyserver olm session version by one. It can be done by executing select * from olm_sessions;. This means that only one encryption is persisted to the db and it is the one that encrypts notification delivered to
the client.
Reviewers: tomek, bartek, atul, ashoat
Reviewed By: tomek
Subscribers: ashoat
Differential Revision: https://phab.comm.dev/D8697