Page MenuHomePhabricator

[lib] Introduce new `sendMultimediaMessage` and consume in `native`
ClosedPublic

Authored by atul on Sep 5 2022, 10:52 PM.
Tags
None
Referenced Files
F3367328: D5063.id16877.diff
Mon, Nov 25, 2:30 PM
Unknown Object (File)
Fri, Nov 22, 11:49 AM
Unknown Object (File)
Fri, Nov 22, 11:10 AM
Unknown Object (File)
Sat, Nov 16, 2:04 AM
Unknown Object (File)
Mon, Nov 11, 2:51 AM
Unknown Object (File)
Tue, Nov 5, 11:29 AM
Unknown Object (File)
Sat, Nov 2, 1:14 PM
Unknown Object (File)
Sat, Nov 2, 1:14 PM
Subscribers

Details

Summary

Introduce a new sendMultimediaMessage in lib/actions/message-actions that hits the create_multimedia_message endpoint with the updated payload (mediaMessageContents instead of mediaIDs).

This endpoint is consumed by input-state-container on native, but not on web. We continue to use the legacySendMultimediaMessage on web to avoid breaking things.

IMPORTANT: While the changes made to keyserver in this stack are backwards compatible, this change to native depends on keyserver being deployed before a release is made. To keep things simple I'll avoid landing this diff until all necessary changes on the keyserver side are made and tested. I'll hold back on landing this diff (and a few others) until we decide to "flip the switch." I'll probably just keep this commit in my local environment as I'm working, but figured it might be helpful for reviewers if they wanted to arc patch or test any part of the stack in their local dev environment.

(As of this diff, the keyserver has everything it needs in multimediaMessageCreationResponder(...) to properly associate uploads with media with messages)


Depends on D5062

Test Plan
  1. Able to send image(s) on native as before without issue
  2. Able to send image(s) on web as before without issue

Also set breakpoints at key parts of the multimedia message flow and ensured that values appeared as expected.

(I'll do some a bunch of additional testing once things are "working" end-to-end)

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

atul requested review of this revision.Sep 5 2022, 11:02 PM
atul edited the summary of this revision. (Show Details)
tomek requested changes to this revision.Sep 8 2022, 8:27 AM

The new and old API differ in only one type, so maybe it would be a good idea to simply have a method that works for both. We're going to throw away the old API so copying code might be a good idea... but now I'm not sure if introducing the new method made sense for legacy shape. We could simply have a function that accepts either type and at the end of process we would delete the old type.

I'm not necessarily requesting to change the code now, but I'm curious about your opinion.

lib/actions/message-actions.js
133 ↗(On Diff #16346)

It's confusing to see db type in an interface between client and server.

This revision now requires changes to proceed.Sep 8 2022, 8:27 AM
lib/actions/message-actions.js
133 ↗(On Diff #16346)

That's totally fair. I couldn't think of a better name, but open to changing it to whatever might be clearer. I thought of just MediaMessageContent but that might imply that it contains the "contents" (eg blobs) of the MediaMessage?

Idk, I just re-used the naming scheme that I used for the message-reducer stuff a while ago but very open to changing name to something clearer

The new and old API differ in only one type, so maybe it would be a good idea to simply have a method that works for both.

We kind of have that on the keyserver side. I put a good amount of thought into supporting old clients with the new keyserver... but didn't think we were too worried about supporting old keyservers with newer clients at this point since there's only one keyserver.

With regards to sendMultimediaMessage and legacySendMultimediaMessage in lib being largely redundant on the client-side, I didn't want to spend too much time refactoring that since legacySendMultimediaMessage will be removed altogether pretty soon in this stack. These functions are only used from the client-side (native and web), so we don't have to worry about "keeping it around" like we have to for functionality on the keyserver side (to support old clients).

We're going to throw away the old API so copying code might be a good idea... but now I'm not sure if introducing the new method made sense for legacy shape. We could simply have a function that accepts either type and at the end of process we would delete the old type.

Yeah we totally could have merged the functionality to handle both types within one function, but I thought it was easier to just split them apart and give them different names rather than add functionality/logic to handle both. If we were keeping both around, I'd certainly refactor to reduce repetition, but going to remove legacy... very quickly so I guess I'm being lazy and this was easier to work with as I'm developing.

(Let me know if I correctly understood your questions, or if there's something I'm missing/should expand on)

(Let me know if I correctly understood your questions, or if there's something I'm missing/should expand on)

I think we're on the same page

but didn't think we were too worried about supporting old keyservers with newer clients at this point since there's only one keyserver.

Yeah, that's right. But at some point it could be necessary to version the keyserver code. Probably the same applies to services. We can't assume that everything will be always up-to-date, because we should have a way to rollback. So that seems like a quite complicated issue. But as we agreed, in this diff we're fine.

Yeah we totally could have merged the functionality to handle both types within one function, but I thought it was easier to just split them apart and give them different names rather than add functionality/logic to handle both. If we were keeping both around, I'd certainly refactor to reduce repetition, but going to remove legacy... very quickly so I guess I'm being lazy and this was easier to work with as I'm developing.

Sounds reasonable.

lib/actions/message-actions.js
133 ↗(On Diff #16346)

I think that adding e.g. descriptor at the end of the name could differentiate between content and just the ids. What do you think about MediaMessageContentDescriptor? (or description, not sure which one sounds more appropriate)

This revision is now accepted and ready to land.Sep 9 2022, 8:37 AM

Now that D5062 has been deployed to production, can this be landed?

Now that D5062 has been deployed to production, can this be landed?

Yeah. I'll patch this in, connect to prod, and send some photo messages as a sanity check... but this should be good to land.