Page MenuHomePhabricator

Extract shareable notifications session creation logic to lib
ClosedPublic

Authored by marcin on Oct 19 2023, 3:36 AM.
Tags
None
Referenced Files
F3389092: D9534.diff
Fri, Nov 29, 5:32 PM
Unknown Object (File)
Sat, Nov 23, 4:30 PM
Unknown Object (File)
Wed, Nov 13, 2:57 AM
Unknown Object (File)
Mon, Nov 11, 1:55 AM
Unknown Object (File)
Oct 29 2024, 7:45 AM
Unknown Object (File)
Oct 29 2024, 7:41 AM
Unknown Object (File)
Oct 29 2024, 7:40 AM
Unknown Object (File)
Oct 29 2024, 7:35 AM
Subscribers

Details

Summary

Most of the logic implemented in useInitialNotificationsEncryptedMessage hook in native folder can be reused for olm session initialisation on web. That said the shareable part it should be moved to lib and only the platform specific part should be kept in native. Additionally this differential introduces necessary changes in native components (mostly boilerplate code).

Test Plan

Using native app ensure that brand new olm session for notifs (select * from olm_sessions; in mariadb console) is created when:

  1. Logging in.
  2. Registering.
  3. Registering with siwe.

Additionally repeat the second part of test plan for D9532 but for native app.

This will ensure that existing functionality relying on olm data on native isn't broken by this differential.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Rebase to update commit message

marcin edited the test plan for this revision. (Show Details)

Realize this is mostly a refactoring diff, but wonder if we should add some error handling or at least logging to useInitialNotificationsEncryptedMessage? Maybe as a follow-up or something

lib/shared/crypto-utils.js
29 ↗(On Diff #32186)

Should we do any error handling in this callback in case any of the steps fail?

This revision is now accepted and ready to land.Oct 23 2023, 10:04 AM
lib/shared/crypto-utils.js
29 ↗(On Diff #32186)

On native this function is used during log-in. That said if it fails then we let the entire log-in fail. This is something we agreed on during work on encrypted notifications. We could try ... catch and let notifications session be created via socket request. However it would probably have similar effect as to simply remove it from log-in and put the responsibility to create notfications session on the socket request which would be retried in case any of those steps fail. So the basic question si whether we want to let the user log-in even if they can't establish notifications session instantly.

Additionally this is lib code so it can be argued whether the actual caller of this function will know better how to handle its failure. This is something I could discuss with @ashoat during 1:1.

Rebase and adapt to new typing