Skip to content

Conversation

stephen-smith
Copy link
Contributor

@stephen-smith stephen-smith commented May 9, 2022

https://wearezeta.atlassian.net/browse/FS-532 (partial, brig changes)

New endpoints are not in use, but brig will need to be deployed before galley, which I think is the status quo.

Checklist

  • The PR Title explains the impact of the change.
  • The PR description provides context as to why the change should occur and what the code contributes to that effect. This could also be a link to a JIRA ticket or a Github issue, if there is one.
  • changelog.d contains the following bits of information (details):
    • A file with the changelog entry in one or more suitable sub-sections. The sub-sections are marked by directories inside changelog.d.
    • If internal end-points have been added or changed: which services have to be deployed in a specific order?

@stephen-smith stephen-smith temporarily deployed to cachix May 9, 2022 21:33 Inactive
@stephen-smith stephen-smith temporarily deployed to cachix May 11, 2022 14:16 Inactive
@stephen-smith stephen-smith temporarily deployed to cachix May 11, 2022 18:04 Inactive
@stephen-smith stephen-smith temporarily deployed to cachix May 11, 2022 21:19 Inactive
@stephen-smith stephen-smith temporarily deployed to cachix May 12, 2022 18:37 Inactive
@stephen-smith stephen-smith marked this pull request as ready for review May 12, 2022 20:25
@stephen-smith stephen-smith temporarily deployed to cachix May 12, 2022 22:55 Inactive
@stephen-smith stephen-smith temporarily deployed to cachix May 13, 2022 19:14 Inactive
@stephen-smith stephen-smith temporarily deployed to cachix May 17, 2022 15:48 Inactive
@stephen-smith stephen-smith temporarily deployed to cachix May 17, 2022 20:49 Inactive
Copy link
Contributor

@pcapriotti pcapriotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but it's not entirely clear to me if this is the API that we'll need. For example, when dereferencing a recipient of a welcome message, it might be useful to fetch both the user and the corresponding conversation at the same time, instead of making two calls to brig.

But this is ok for now, we can always add more endpoints later.

@@ -201,6 +217,87 @@ testFeatureConferenceCallingByAccount (Opt.optSettings -> settings) mgr db brig
check $ ApiFt.TeamFeatureStatusNoConfig ApiFt.TeamFeatureDisabled
check'

keyPackageCreate :: HasCallStack => Brig -> Http KeyPackageRef
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this test basically contained in testKeyPackageClaim in API.MLS?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a test itself, it's a helper function to get a valid, claimed ref.

Comment on lines +249 to +258
kpcPut :: HasCallStack => Brig -> KeyPackageRef -> Qualified ConvId -> Http ()
kpcPut brig ref qConv = do
resp <-
put
( brig
. paths ["i", "mls", "key-packages", toByteString' $ toUrlPiece ref, "conversation"]
. contentJson
. json qConv
)
liftIO $ assertEqual "PUT i/mls/key-packages/:ref/conversation failed" 204 (statusCode resp)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
kpcPut :: HasCallStack => Brig -> KeyPackageRef -> Qualified ConvId -> Http ()
kpcPut brig ref qConv = do
resp <-
put
( brig
. paths ["i", "mls", "key-packages", toByteString' $ toUrlPiece ref, "conversation"]
. contentJson
. json qConv
)
liftIO $ assertEqual "PUT i/mls/key-packages/:ref/conversation failed" 204 (statusCode resp)
kpcPut brig ref qConv =
put
( brig
. paths ["i", "mls", "key-packages", toByteString' $ toUrlPiece ref, "conversation"]
. contentJson
. json qConv
)
!!! const 204 === statusCode

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I prefer the custom message, since this failure might occur inside 3-4 different tests.

q = "SELECT conv_domain, conv FROM mls_key_package_refs WHERE ref = ?"

-- We want to proper update, not an upsert, to avoid "ghost" refs without user+client
keyPackageRefSetConvId :: MonadClient m => KeyPackageRef -> Qualified ConvId -> m Bool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably ok, but we might also want to consider the more simple-minded approach of checking existence first, then updating, as we do in various other places.

@mdimjasevic
Copy link
Contributor

For example, when dereferencing a recipient of a welcome message, it might be useful to fetch both the user and the corresponding conversation at the same time, instead of making two calls to brig.

I had this in PR #2368 (commit 320c309), but later I realised I don't need it for that PR and reverted the commit. @stephen-smith , feel free to adopt it as part of your PR.

@stephen-smith
Copy link
Contributor Author

For example, when dereferencing a recipient of a welcome message, it might be useful to fetch both the user and the corresponding conversation at the same time, instead of making two calls to brig.

I had this in PR #2368 (commit 320c309), but later I realised I don't need it for that PR and reverted the commit. @stephen-smith , feel free to adopt it as part of your PR.

I didn't want to change the public API (and disrupt other teams) for this intra-service communication feature, since it's still on the horizon to merge galley and brig, but I'll look into it. One query to grab the whole row is going to be more efficient for the computers, certainly.

@stephen-smith
Copy link
Contributor Author

For example, when dereferencing a recipient of a welcome message, it might be useful to fetch both the user and the corresponding conversation at the same time, instead of making two calls to brig.

I had this in PR #2368 (commit 320c309)

I didn't want to change the public API

Hmm, that's actually in the Internal API. Going to merge as-is for now, but since both those queries are internal I might merge them as part of the next round of changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants