Page MenuHomePhabricator

[native] Encrypt files during media mission
ClosedPublic

Authored by bartek on Mar 29 2023, 7:04 AM.
Tags
None
Referenced Files
F3515624: D7236.diff
Sun, Dec 22, 9:21 AM
Unknown Object (File)
Sat, Dec 14, 4:49 PM
Unknown Object (File)
Sat, Dec 14, 4:49 PM
Unknown Object (File)
Sat, Dec 14, 4:49 PM
Unknown Object (File)
Sat, Dec 14, 4:49 PM
Unknown Object (File)
Sat, Dec 14, 4:42 PM
Unknown Object (File)
Thu, Dec 5, 8:35 PM
Unknown Object (File)
Wed, Dec 4, 3:28 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