Page MenuHomePhabricator

[lib] DMOperationSpec for CREATE_THREAD operation
ClosedPublic

Authored by ashoat on Jul 3 2024, 7:58 PM.
Tags
None
Referenced Files
F3352509: D12658.id41985.diff
Sat, Nov 23, 6:13 AM
F3352447: D12658.id41989.diff
Sat, Nov 23, 5:58 AM
F3352260: D12658.id42057.diff
Sat, Nov 23, 5:18 AM
F3352236: D12658.id42138.diff
Sat, Nov 23, 5:11 AM
F3351612: D12658.diff
Sat, Nov 23, 2:47 AM
Unknown Object (File)
Wed, Nov 20, 11:48 PM
Unknown Object (File)
Mon, Nov 11, 5:12 AM
Unknown Object (File)
Sun, Nov 10, 10:49 PM
Subscribers
None

Details

Summary

Handles creating all ThickThreadTypes, including sidebars.

The RawThreadInfo construction was loosely inspired by createPendingThread, but it's different because pending threads are intentionally constructed to have limited permissions, so eg. the user can't go the settings of a pending thread.

Depends on D12657

Test Plan

I haven't tested this stack outside of Flow. I'd like to propose that we land this so the team can iterate. I'll make sure to test all of the functionality once it's integrated into the rest of the codebase.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

lib/shared/dm-ops/create-thread-spec.js
51–64 ↗(On Diff #41979)

This part modelled after createPendingThread

66 ↗(On Diff #41979)

Cast as { ...ThickRawThreadInfo } to get rid of read-only

109 ↗(On Diff #41979)

The only await necessary. I think we will need to query SQLite here

110–114 ↗(On Diff #41979)

The caller will have a try-catch around calls around processDMOperation. If we fail to process a DMOperation, I think we should probably just print an error to the console and otherwise ignore it

119–158 ↗(On Diff #41979)

This part modelled after thread-creator.js on the keyserver

Harbormaster returned this revision to the author for changes because remote builds failed.Jul 3 2024, 8:11 PM
Harbormaster failed remote builds in B30108: Diff 41979!
lib/shared/dm-ops/create-thread-spec.js
51–64 ↗(On Diff #41985)

This part modelled after createPendingThread

66 ↗(On Diff #41985)

Cast as { ...ThickRawThreadInfo } to get rid of read-only

109 ↗(On Diff #41985)

The only await necessary. I think we will need to query SQLite here

110–114 ↗(On Diff #41985)

The caller will have a try-catch around calls around processDMOperation. If we fail to process a DMOperation, I think we should probably just print an error to the console and otherwise ignore it

119–158 ↗(On Diff #41985)

This part modelled after thread-creator.js on the keyserver

Harbormaster returned this revision to the author for changes because remote builds failed.Jul 3 2024, 8:32 PM
Harbormaster failed remote builds in B30114: Diff 41985!
ashoat requested review of this revision.Jul 3 2024, 9:06 PM
lib/shared/dm-ops/create-thread-spec.js
51–64 ↗(On Diff #41989)

This part modelled after createPendingThread

66 ↗(On Diff #41989)

Cast as { ...ThickRawThreadInfo } to get rid of read-only

109 ↗(On Diff #41989)

The only await necessary. I think we will need to query SQLite here

110–114 ↗(On Diff #41989)

The caller will have a try-catch around calls around processDMOperation. If we fail to process a DMOperation, I think we should probably just print an error to the console and otherwise ignore it

119–158 ↗(On Diff #41989)

This part modelled after thread-creator.js on the keyserver

lib/shared/dm-ops/create-thread-spec.js
133 ↗(On Diff #41989)

I should actually update this. I initially was thinking that it's not important because only receiving clients will process this, and it looks like sourceMessageAuthorID is only used for notifs.

But now I'm thining the sending client will probably call processDMOperation to generate the RawMessageInfos that are stored locally, and will use the result to generate notifs. We have access to the sourceMessage above, so it should be simple to set this correctly

162 ↗(On Diff #41989)

These ids are only used for UpdateInfos on the keyserver side... they don't matter at all on the client side. At some point we probably should have changed the types to remove them, and I suppose we should still do that now... but it's tough to prioritize it given our launch schedule

Created ENG-8713 as a follow-up

  1. Actually pass sourceMessageAuthorID in based on sourceMessage
  2. Decided to use a UUID instead of 'ignored'. I'm pretty sure it's not used on the client anywhere, but figured it's better to avoid any risks in case it affects anything, given our tight timeline for launch
lib/shared/dm-ops/create-thread-spec.js
52–65 ↗(On Diff #42057)

This part modelled after createPendingThread

67 ↗(On Diff #42057)

Cast as { ...ThickRawThreadInfo } to get rid of read-only

110 ↗(On Diff #42057)

The only await necessary. I think we will need to query SQLite here

111–115 ↗(On Diff #42057)

The caller will have a try-catch around calls around processDMOperation. If we fail to process a DMOperation, I think we should probably just print an error to the console and otherwise ignore it

120–159 ↗(On Diff #42057)

This part modelled after thread-creator.js on the keyserver

tomek added inline comments.
lib/shared/dm-ops/create-thread-spec.js
80 ↗(On Diff #42057)

allMemberIDs contains creatorID for whom we should probably set isSender to true.

91 ↗(On Diff #42057)

Is it possible that this condition is true?

95–109 ↗(On Diff #42057)

Shouldn't we merge these two ifs?

122 ↗(On Diff #42057)

Are we relying somewhere on this ID schema? I think that using a deterministic ID could cause some issues, e.g. when we create a pending DM thread, add a new user, and then create a new DM thread with the original set of users. I'm not sure if threadID could be a "pending thread ID" - but if yes, then the described scenario will cause a conflict between message IDs. Can we use UUIDs instead for the role and all the created messages?

This revision is now accepted and ready to land.Jul 5 2024, 5:09 AM
lib/shared/dm-ops/create-thread-spec.js
80 ↗(On Diff #42057)

Good catch

91 ↗(On Diff #42057)

Yes, I think that we'll call processDMOperation on all recipients – both the devices of the user, and the devices of their peers

95–109 ↗(On Diff #42057)

Will merge

122 ↗(On Diff #42057)

Are we relying somewhere on this ID schema? I think that using a deterministic ID could cause some issues, e.g. when we create a pending DM thread, add a new user, and then create a new DM thread with the original set of users. I'm not sure if threadID could be a "pending thread ID" - but if yes, then the described scenario will cause a conflict between message IDs.

In this case, threadID should be a non-pending threadID. So I don't think that hypothetical could occur.

Can we use UUIDs instead for the role and all the created messages?

I suppose this would be safer, but it would require extending DMCreateThreadOperation to include UUIDs for all of these, which might be a little messy.

Addressed all feedback. Decided to create a separate create_sidebar spec