[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...
- Go through each MediaMessageServerDBContent and aggregate uploadIDs
- Query the uploads table for the id, secret, type, and extra of each upload
- 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).
Reviewers: abosh, tomek, marcin
Reviewed By: tomek
Subscribers: ashoat
Differential Revision: https://phab.comm.dev/D5085