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, Dec 16, 4:07 AM
Unknown Object (File)
Sun, Dec 1, 12:01 PM
Unknown Object (File)
Nov 22 2024, 11:24 AM
Unknown Object (File)
Nov 22 2024, 6:05 AM
Unknown Object (File)
Nov 11 2024, 2:51 AM
Unknown Object (File)
Nov 2 2024, 1:14 PM
Unknown Object (File)
Nov 2 2024, 1:14 PM
Unknown Object (File)
Nov 2 2024, 1:14 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
Branch
master
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

atul requested review of this revision.Sep 9 2022, 2:35 AM
keyserver/src/updaters/upload-updaters.js
27–32

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

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

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 ↗(On Diff #16714)

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 ↗(On Diff #16714)

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