Page MenuHomePhabricator

Introduce fallback mechanism for notifications decryption if MMKV initialization hasn't been executed yet.
ClosedPublic

Authored by marcin on Wed, Apr 3, 6:40 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Apr 14, 3:28 PM
Unknown Object (File)
Sun, Apr 14, 2:58 PM
Unknown Object (File)
Sat, Apr 13, 6:33 PM
Unknown Object (File)
Sat, Apr 13, 12:11 PM
Unknown Object (File)
Fri, Apr 12, 12:58 PM
Unknown Object (File)
Thu, Apr 11, 10:02 AM
Unknown Object (File)
Wed, Apr 10, 3:40 PM
Unknown Object (File)
Wed, Apr 10, 10:54 AM
Subscribers

Details

Summary

This differential fixes: https://linear.app/comm/issue/ENG-7309/nse-received-c-exception-nse-cant-initialize-mmkv-encryption-key. If decryption with session
stored in MMKV failes (since MMKV wasn't initialized yet) we try to use previous file-based session.

Test Plan
  1. Revert this diff and the diff that migrates notifs session to MMKV. For the second reosolve the conflicts by making migration 38 a no-op.
  2. Build the app and log in. This puts the app in legacy notifications state - notifications session is created in a flat file.
  3. Reset reveerts, build the app again and send notifications.
  4. Ensure notifications are working since the fallback mechanism uses old session.
  5. Log out and log in again. Ensure that notifs are still working - new approach is working as well.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

native/cpp/CommonCpp/Notifications/BackgroundDataStorage/NotificationsCryptoModule.cpp
87–148 ↗(On Diff #38730)

This code is a copy-paste of a function that was introduced last year when encrypted notifications were introduced. No review is necessary here.

native/ios/NotificationService/NotificationService.mm
181 ↗(On Diff #38730)

Originally this if statement would fail the notif the public user if they upgraded app version but didn't open the app after upgrading. This change will:

  • make the NSE use badge count delivered with notif in case MMKV wasn't initialized (public user)
  • display error message notification for staff user (previous behaviour).
marcin requested review of this revision.Wed, Apr 3, 6:56 AM

Please prioritize the review of this diff as it solves a long-standing urgent issue breaking notifs for all users

Looks good

native/cpp/CommonCpp/Notifications/BackgroundDataStorage/NotificationsCryptoModule.cpp
416–422 ↗(On Diff #38730)

I am wondering if this is the right approach, and shouldn't we e.g. modify fetchNotificationsSession to return false, null, or some special value?

I am thinking about too wide range of exceptions, if this fails for a different reason than migration not executed yet, what should we do?

420 ↗(On Diff #38730)

in this context - the name of this method is a bit confusing but I can't think of anything better

native/cpp/CommonCpp/Notifications/BackgroundDataStorage/NotificationsCryptoModule.h
55–56 ↗(On Diff #38730)

How about making those protected without getters and setters?

103 ↗(On Diff #38730)

nit: for me using this twice in one class decrease readabillity

This revision is now accepted and ready to land.Thu, Apr 4, 5:11 AM

This issue needs to be fixed ASAP. It's disappointing to see this diff has been sitting in an accepted state for over 24 hours, while @marcin has prioritized other work. There is nothing else that matters more than resolving an urgent issue that breaks notifs for all users. I'm not sure how else to emphasize this.

  1. Address Kamil feedback
  2. Rebase before landing