Page MenuHomePhabricator

[native] Encrypt files during media mission
ClosedPublic

Authored by bartek on Mar 29 2023, 7:04 AM.
Tags
None
Referenced Files
F1672998: D7236.id.diff
Sun, Apr 28, 7:57 AM
F1671899: D7236.diff
Sun, Apr 28, 1:08 AM
F1671297: D7236.id24536.diff
Sat, Apr 27, 9:00 PM
F1671293: D7236.id24333.diff
Sat, Apr 27, 8:59 PM
F1671284: D7236.id24481.diff
Sat, Apr 27, 8:59 PM
F1671225: D7236.id.diff
Sat, Apr 27, 8:55 PM
F1671180: D7236.diff
Sat, Apr 27, 8:30 PM
Unknown Object (File)
Fri, Apr 26, 7:56 AM
Subscribers

Details

Summary

This is final diff that allows sending encrypted messages on native. The shouldEncryptMedia boolean has been introduced as a feature flag. Now it's hardcoded to false, but we want to enable it only for Comm community (ENG-3526) - this will be done in another diff.

The whole function becomes kind of spaghetti - a refactor follow-up wouldn't be a bad idea

Depends on D7234, D7235

Test Plan

Sending multimedia works as before when the flag is false.
Set it to true, then send both photos and videos. Ensure both work as expected

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

bartek held this revision as a draft.
bartek published this revision for review.Mar 30 2023, 4:50 AM
bartek edited the summary of this revision. (Show Details)

The whole function becomes kind of spaghetti - a refactor follow-up wouldn't be a bad idea

Ah dang, InputStateContainer is already one of the most difficult to understand places in the codebase for me. Strongly agree we should refactor at some point, but probably not a priority at the moment.

This revision is now accepted and ready to land.Mar 30 2023, 8:14 AM
ashoat added inline comments.
native/input/input-state-container.react.js
163 ↗(On Diff #24333)
817 ↗(On Diff #24333)

Does this mean that we will have encryptionKey: undefined in the uploads.extras MySQL column for non-encrypted uploads? If so, can we avoid that?

895 ↗(On Diff #24333)

It might be possible to do something like this instead:

let payload: UpdateMultimediaMessageMediaPayload;
if (updateMediaPayload.mediaUpdate.type === 'encrypted_video') {
  payload = {
    ...updateMediaPayload,
    mediaUpdate: {
      ...updateMediaPayload.mediaUpdate,
      thumbnailID,
      ...thumbnailSourcePayload,
    },
  };
} else {
  // Same as above, for Flow
  payload = {
    ...updateMediaPayload,
    mediaUpdate: {
      ...updateMediaPayload.mediaUpdate,
      thumbnailID,
      ...thumbnailSourcePayload,
    },
  };
}

However, because we don't do the same thing on lines 850 and 862, it's likely that Flow won't be able to conclude that payload really is UpdateMultimediaMessageMediaPayload. This would probably require a lot of boilerplate to type correctly...

native/input/input-state-container.react.js
817 ↗(On Diff #24333)

We're already avoiding that here

895 ↗(On Diff #24333)

This if-else fixed it, but I got rid of thumbnailSourcePayload and put these directly. It's less concise but solved Flow complaints