HomePhabricator
Diffusion Comm e1393cd7d41f

[keyserver] Introduce `fetchMediaFromMediaMessageContent(...)`

Description

[keyserver] Introduce fetchMediaFromMediaMessageContent(...)

Summary:
Given a viewer: Viewer and mediaMessageContents: $ReadOnlyArray<MediaMessageServerDBContent, fetchMediaFromMediaMessageContent(...) will query the serverDB uploads table and return array of "reconstructed" Media.

At a high level...

  1. Go through each MediaMessageServerDBContent and aggregate uploadIDs
  2. Query the uploads table for the id, secret, type, and extra of each upload
  3. Go through each mediaMessageContent and construct corresponding Media by (A) pulling out information from primaryUpload and (B) pulling out information from the thumbnailUpload in the case of videos

The functionality of this function was inspired by the existing fetchMedia(...) and mediaFromRow(...) functionality in upload-fetchers.js... and will replace their usage in the non-legacy multimediaMessageCreationResponder(...)


Depends on D5063

Test Plan:
Added the following:

if (request.mediaMessageContents) {
  const retval = await fetchMediaFromMediaMessageContent(
    viewer,
    request.mediaMessageContents,
  );
}

to message-responders: multimediaMessageCreationResponder(...) so fetchMediaFromMediaMessageContent(...) would be hit every time I sent a media message from the native app.

I set breakpoints throughout fetchMediaFromMediaMessageContent(...) and sent media messages with:

  • 1 photo
  • >1 photos
  • 1 video
  • >1 videos
  • 1 photo + 1 video
  • 2 photos + 2 videos

and observed that values at each step were as expected (taking special care to ensure that IDs were strings and numbers where they were supposed to be).

Screen Shot 2022-09-09 at 2.19.36 AM.png (978×2 px, 827 KB)

Reviewers: abosh, tomek, marcin

Reviewed By: tomek

Subscribers: ashoat

Differential Revision: https://phab.comm.dev/D5085

Details

Provenance
atulAuthored on Sep 13 2022, 2:58 PM
Reviewer
tomek
Differential Revision
D5085: [keyserver] Introduce `fetchMediaFromMediaMessageContent(...)`
Parents
rCOMM70ed8a7b9d35: [Services] Remove Arc usage
Branches
Unknown
Tags
Unknown