Page MenuHomePhabricator

Utilities to idempotently create content and notif sessions
Needs ReviewPublic

Authored by marcin on Thu, Jul 4, 9:33 AM.

Details

Reviewers
tomek
inka
Summary

This differential modifies utility function that creates content session to create both content and notif sessions idempotently

Test Plan
  1. Apply this stash: https://gist.github.com/marcinwasowicz/047b0f1b00079562b2547ebe3a8c18ad. This stash does some of the work https://linear.app/comm/project/send-encrypted-notification-from-the-client-to-the-tunnelbroker-03fc019ed3ee/issues is supposed to do. Message reducer is modified to return MessageData array and db-ops-handler greedily consumes MessageData array to create and send encrypted notifications through TB.
  2. Send text message from a client (any platform).
  3. Ensure that the first time you send message there are logs indicating that session are created with particular device ids (thread members device ids).
  4. Ensure that each time you see in the console logged payloads of encrypted notifications. Examine payloads. Ensure that they match relevant flow types. No notification will be displayed on the receiving client since they can't decrypt the notif yet.

Diff Detail

Repository
rCOMM Comm
Branch
marcin/eng-8237
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

marcin requested review of this revision.Thu, Jul 4, 9:54 AM

I am afraid that there is a vulnerability in this diff. Basically it is possible that two createOlmSessionWithPeer promises will execute concurrently. This might lead to corrupted state. In order to mitigate that I think it is best expose this method as a context. The context would internally keep a map like [(userID, deviceID)] : Promise mapping from particular deviceID and userID to currently executing promise (if any).