Page MenuHomePhabricator

[keyserver] Introduce `assignMessageContainerToMedia(...)` in `upload-updaters`
ClosedPublic

Authored by atul on Sep 9 2022, 2:25 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Apr 22, 12:50 PM
Unknown Object (File)
Tue, Apr 16, 11:30 AM
Unknown Object (File)
Mon, Apr 15, 8:42 PM
Unknown Object (File)
Mon, Apr 15, 3:56 PM
Unknown Object (File)
Mon, Apr 15, 11:10 AM
Unknown Object (File)
Sun, Apr 14, 7:57 AM
Unknown Object (File)
Sat, Apr 13, 8:04 PM
Unknown Object (File)
Sat, Apr 13, 3:56 PM
Subscribers

Details

Summary

Pretty much assignMedia(...) but accepts mediaMessageContents: $ReadOnlyArray<MediaMessageServerDBContent> instead of mediaIDs: $ReadOnlyArray<string>.

The intention is to use assignMessageContainerToMedia(...) in the "new"/non-legacy multimediaMessageCreationResponder(...)


Depends on D5086

Test Plan

Later in the stack this function is "consumed" from multimediaMessageCreationResponder(...). I set some breakpoints and confirmed that values were as expected. I also checked the uploads table in my local MySQL DB and found that the container column was assigned as expected:

b086ef.png (278×2 px, 312 KB)

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

atul requested review of this revision.Sep 9 2022, 2:35 AM
keyserver/src/updaters/upload-updaters.js
27–32 ↗(On Diff #16533)

We're using nearly identical logic in fetchUploadsForMessage(...). Don't think it's quite worth extracting out into it's own utility function yet... but it's on my radar as the stack progresses

tomek requested changes to this revision.Sep 13 2022, 10:30 AM

The code looks ok, but wanted to clarify some things before I can accept.

keyserver/src/updaters/upload-updaters.js
36 ↗(On Diff #16533)

This function is slightly confusing, because it tells that it's going to assign to a container, but only does that if the container isn't already assigned. Should we remove IS NULL condition?

Also, what is the purpose of uploader check?

This revision now requires changes to proceed.Sep 13 2022, 10:30 AM
keyserver/src/updaters/upload-updaters.js
36 ↗(On Diff #16533)

This function is slightly confusing, because it tells that it's going to assign to a container, but only does that if the container isn't already assigned. Should we remove IS NULL condition?

We don't want to return any uploads that have already been assigned a container. This is an assumption made in assignMedia(...) which this function is heavily inspired by. Changing this assumption may (?) break the idempotency of multimediaMessageCreationResponder(...). See the following for context: https://phab.comm.dev/D2476

Also, what is the purpose of uploader check?

Matches the behavior of the existing assignMedia(...)

atul requested review of this revision.Sep 13 2022, 3:48 PM
This revision is now accepted and ready to land.Sep 15 2022, 9:22 AM
keyserver/src/updaters/upload-updaters.js
26–32

Seen this logic pop up in multiple places... wonder if there should be a helper for it instead of copy-pasting

keyserver/src/updaters/upload-updaters.js
26–32

Yeah was going to defer refactoring work for later, but this was quick enough: https://phab.comm.dev/D5190