-
Notifications
You must be signed in to change notification settings - Fork 332
[Federation] Add an Endpoint for Conversation Member Removal based on Qualified User ID #1697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mdimjasevic
merged 125 commits into
develop
from
mdimjasevic/mdimjasevic/fed-leave-remote-conv
Aug 27, 2021
Merged
Changes from all commits
Commits
Show all changes
125 commits
Select commit
Hold shift + click to select a range
62308a9
Make conversation ID qualified in removing a member
4942588
Make the ID of the user to be removed from a conversation qualified
1c56c34
Simple renaming and refactoring towards qualified conv leaving
40a1c0e
Introduce signatures for two local functions
a8dafab
Migrate DELETE /conversations/:cnv/members/:usr to Servant
e596a18
HLS improvements
7961818
Fix compilation issues and remove an unused handler
d25481e
Renaming of unqualified conversation tests
a9a7c06
Introduce the main endpoint and a test for the local domain case only
b2393ab
Apply eta reduction suggested by HLS
2e99d3c
Add a federation gRPC endpoint and a stub handler
80a3a27
WIP: a test for removing members from a a non-existing conversation
77c1b48
Fix up response types and remove unfinished federation tests
688acd8
Unqualify the conversation ID
9bdf11b
Update a test for local conversations
ecd907a
Use ExceptT in removeMemberFromLocalConv
d20f409
Fix a compilation error after merging
732d35a
Minor polishing
c771759
Generalize a Galley integration test utility
1c4df7e
Function renaming to better reflect their purpose
b6c0294
Binding renaming to better reflect what it contains
3e8ccb3
Add a member removal utility function for remote backends
ef390f5
Notify remote backends of conversation members removed
53d8757
Add a HasCallStack constraint to an integration test utility
b8c6ea5
Update the changelog with the deprecated endpoint
c7d03a5
Introduce a conversation event type for removing qualified members
03ab66f
A conversation membership update can either add or remove users
3cfa613
Backwards compatibility: return the MemberLeave Event type
f643945
Add a federated test for a conversation membership update
cb7b4a8
Membership handler: pull out common parts from distinct cases
9bde3b0
Fix a couple of small documentation errors
7375e8e
There must be at least 1 member in a conversation membership update
00af6c7
Use the right backwards compatibility flag in an old endpoint handler
9ffcbab
Fix the usage of randomUser in federation tests
660b0e3
Update a federation test description
7d7b014
Update a comment next to the qualified endpoint for member removal
1c6e33f
Make two more errors explicit in the type of Update.removeMember
1a6dc9e
Minor documentation improvement and removing commented out code
0e5ba1b
Finish expressing the errors of Update.removeMember via its type
54b9a93
Remove unneeded class instances
41392c0
Remove an unused type constraint on a test utility
8e7a923
Add an integration test for removing a local user
d1c2412
Update the change log
e28f05d
Add documentation for the ConversationMembersAction type
2c4cba7
Fix the documentation of a module
a6610b0
Update the description of a federation test
fe1b8d8
Move the non-empty list with origin type to an appropriate module
beb67ea
Fix a typo
903a7ae
Make deprecatedSchema more general
3286b21
Make UserIdList take a list of qualified user IDs
9666ad7
Remove the MemberLeaveQualified conversation event type
5452f08
Remove the even backwards compatibility flag
4ff5dab
The removal endpoint takes a qualified conversation ID
4ef9639
Introduce several integration test utilities
0330e0b
Avoid repeating: use an integration test utility
12d553c
Add a currently failing test
db2c283
Update an endpoint comment
6aeb720
Add a Haddock for Update.removeMember
c484569
Make sure remote conversation members can't remove others
4b70097
Change a function input type so it is constrained in usage
8be7be0
Add documentation for a function's arguments
47d77f8
Generalize a few Galley member utilities
57fe56a
Further generalize conversation member utilities
be576e6
Make remover qualified in Update.removeMember
69e99a5
Add an endpoint: DELETE /federation/leave-conversation
50274dd
A minor readability improvement
d457eaa
Finish implementing the leaving of a remote conversation
81f59aa
Fix a typo in the documentation
599d877
Get rid of the QualifiedUserIdList type
b4d65db
Change a TODO into a FUTUREWORK
7702cab
Reuse a testing utility instead of writing it from scratch
b797480
Fix compile errors after rebase
akshaymankar e52807d
Ormolu
akshaymankar 178abec
Fix the JSON instances for team events
1a94a46
Rename a field of the ConversationMemberUpdate record
87d5a28
Redo removing a leftover
4a0e383
Update services/galley/src/Galley/API/Util.hs
84178ff
Simplify responses for conversation member removal
71e0166
Get rid of a special case for leaving a conversation
87acd10
Use only POST and HTTP 200 in federation api for leaving conv
fb304df
Make swagger prettier for multiple qualified captures
31a2873
removeMembersFromLocalConv: Delete function
b2e7a7a
addToConversaion: Accept two simple lists
6dd82d1
Improve Haddock of a function
2cebe78
Use NonEmpty in ConversationMemberAction
58db4ec
Delete List1WithOrigin
475f088
Use unless to have less indentation
03dd46b
Simplify removeMemberFromLocalConv
187d2ca
Fix an integration test
7b7f984
Add a golden test for /federation/leave-conversation
f98e83b
Add a few golden tests for ConversationMemberUpdate
f03a73b
Create events for the leaving local user locally
akshaymankar 88b3860
Remove stray comment
akshaymankar 7efc6fd
Remove unnecessary Read instance
akshaymankar 830039f
Render the qualified ids under "qualified_user_ids" for UserIdList
akshaymankar dac3221
Reduce number of golden tests for UserIdList
akshaymankar c28ad86
Refactor code to notify remotes of conversation changes
akshaymankar 2738421
Refactor notifyRemoteAboutConvUpdate to only take ConvId
akshaymankar 2ca51f3
Better comment
akshaymankar dfabf76
Remove redundant import
akshaymankar 2568825
Better names for integration tests
akshaymankar 1301700
Refactor tests to avoid levels of indentations
akshaymankar 21ce56f
Merge branch 'develop' into mdimjasevic/mdimjasevic/fed-leave-remote-…
akshaymankar 124f12d
WIP: Add test to delete a remote member
akshaymankar 5911c88
Delete unnecessary function and Ormolu
akshaymankar b9f0e79
Remove unnecessary mocking
akshaymankar 5b2ac84
Add assertions for the membership update
akshaymankar a5ac7b2
undo undid hlint
akshaymankar 3f0b6c6
Remove unnecessary variable
akshaymankar e084cb5
Create conversation with qualified users using one call
akshaymankar 3a5f0c1
Add test for trying to remove local user from remote conv
akshaymankar a4cc2a4
Avoid using Cql directly from fed integration tests
akshaymankar c72689c
WIP: Add test for /federation/leave-conversation
akshaymankar c605a86
Ormolu
akshaymankar aa0e7b9
Finish WIP for federated leave conversion endpoint
akshaymankar bbf3511
Cosmetic undo
akshaymankar 05487b0
Undo making EDMemberLeave qualified
akshaymankar 35b09a0
Make UserIdList unqualified so it can be used for team things
akshaymankar 3780cc7
Fix compilation errors in brig tests
akshaymankar e1af680
Fix compile issues
akshaymankar bd5fd9f
Add e2e test, not tested locally
akshaymankar 5d2f850
Merge branch 'develop' into mdimjasevic/mdimjasevic/fed-leave-remote-…
akshaymankar d3f3249
Ormolu
akshaymankar 26627f2
Add E2E test for leaving a conversation
akshaymankar e8be744
Ormolu
akshaymankar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
libs/wire-api-federation/test/Test/Wire/API/Federation/Golden/ConversationMemberUpdate.hs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| -- This file is part of the Wire Server implementation. | ||
| -- | ||
| -- Copyright (C) 2021 Wire Swiss GmbH <opensource@wire.com> | ||
| -- | ||
| -- This program is free software: you can redistribute it and/or modify it under | ||
| -- the terms of the GNU Affero General Public License as published by the Free | ||
| -- Software Foundation, either version 3 of the License, or (at your option) any | ||
| -- later version. | ||
| -- | ||
| -- This program is distributed in the hope that it will be useful, but WITHOUT | ||
| -- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| -- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more | ||
| -- details. | ||
| -- | ||
| -- You should have received a copy of the GNU Affero General Public License along | ||
| -- with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
|
||
| module Test.Wire.API.Federation.Golden.ConversationMemberUpdate where | ||
|
|
||
| import Data.Domain (Domain (Domain)) | ||
| import Data.Id (Id (Id), UserId) | ||
| import Data.List.NonEmpty (NonEmpty (..)) | ||
| import Data.Qualified (Qualified (Qualified)) | ||
| import qualified Data.UUID as UUID | ||
| import Imports | ||
| import Wire.API.Conversation.Role (roleNameWireAdmin, roleNameWireMember) | ||
| import Wire.API.Federation.API.Galley (ConversationMemberUpdate (..), ConversationMembersAction (..)) | ||
|
|
||
| qAlice, qBob :: Qualified UserId | ||
| qAlice = | ||
| Qualified | ||
| (Id (fromJust (UUID.fromString "00000000-0000-0000-0000-000100004007"))) | ||
| (Domain "golden.example.com") | ||
| qBob = | ||
| Qualified | ||
| (Id (fromJust (UUID.fromString "00000000-0000-0000-0000-000100005007"))) | ||
| (Domain "golden2.example.com") | ||
|
|
||
| chad, dee :: UserId | ||
| chad = Id (fromJust (UUID.fromString "00000fff-0000-0000-0000-000100005007")) | ||
| dee = Id (fromJust (UUID.fromString "00000fff-0000-aaaa-0000-000100005007")) | ||
|
|
||
| testObject_ConversationMemberUpdate1 :: ConversationMemberUpdate | ||
| testObject_ConversationMemberUpdate1 = | ||
| ConversationMemberUpdate | ||
| { cmuTime = read "1864-04-12 12:22:43.673 UTC", | ||
| cmuOrigUserId = | ||
| Qualified | ||
| (Id (fromJust (UUID.fromString "00000000-0000-0000-0000-000100000007"))) | ||
| (Domain "golden.example.com"), | ||
| cmuConvId = | ||
| Qualified | ||
| (Id (fromJust (UUID.fromString "00000000-0000-0000-0000-000100000006"))) | ||
| (Domain "golden2.example.com"), | ||
| cmuAlreadyPresentUsers = [], | ||
| cmuAction = ConversationMembersActionAdd ((qAlice, roleNameWireMember) :| [(qBob, roleNameWireAdmin)]) | ||
| } | ||
|
|
||
| testObject_ConversationMemberUpdate2 :: ConversationMemberUpdate | ||
| testObject_ConversationMemberUpdate2 = | ||
| ConversationMemberUpdate | ||
| { cmuTime = read "1864-04-12 12:22:43.673 UTC", | ||
| cmuOrigUserId = | ||
| Qualified | ||
| (Id (fromJust (UUID.fromString "00000000-0000-0000-0000-000100000007"))) | ||
| (Domain "golden.example.com"), | ||
| cmuConvId = | ||
| Qualified | ||
| (Id (fromJust (UUID.fromString "00000000-0000-0000-0000-000100000006"))) | ||
| (Domain "golden2.example.com"), | ||
| cmuAlreadyPresentUsers = [chad, dee], | ||
| cmuAction = ConversationMembersActionRemove (qAlice :| [qBob]) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
libs/wire-api-federation/test/Test/Wire/API/Federation/Golden/LeaveConversationRequest.hs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| -- This file is part of the Wire Server implementation. | ||
| -- | ||
| -- Copyright (C) 2021 Wire Swiss GmbH <opensource@wire.com> | ||
| -- | ||
| -- This program is free software: you can redistribute it and/or modify it under | ||
| -- the terms of the GNU Affero General Public License as published by the Free | ||
| -- Software Foundation, either version 3 of the License, or (at your option) any | ||
| -- later version. | ||
| -- | ||
| -- This program is distributed in the hope that it will be useful, but WITHOUT | ||
| -- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| -- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more | ||
| -- details. | ||
| -- | ||
| -- You should have received a copy of the GNU Affero General Public License along | ||
| -- with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
|
||
| module Test.Wire.API.Federation.Golden.LeaveConversationRequest where | ||
|
|
||
| import Data.Id (Id (Id)) | ||
| import Data.Maybe (fromJust) | ||
| import qualified Data.UUID as UUID | ||
| import Wire.API.Federation.API.Galley (LeaveConversationRequest (LeaveConversationRequest)) | ||
|
|
||
| testObject_LeaveConversationRequest1 :: LeaveConversationRequest | ||
| testObject_LeaveConversationRequest1 = | ||
| LeaveConversationRequest | ||
| (Id (fromJust (UUID.fromString "00000000-0000-0000-0000-000100000002"))) | ||
| (Id (fromJust (UUID.fromString "00000000-0000-0000-0000-000100000001"))) |
32 changes: 32 additions & 0 deletions
32
libs/wire-api-federation/test/Test/Wire/API/Federation/Golden/LeaveConversationResponse.hs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| module Test.Wire.API.Federation.Golden.LeaveConversationResponse where | ||
|
|
||
| import Imports | ||
| import Wire.API.Federation.API.Galley (LeaveConversationResponse (LeaveConversationResponse)) | ||
| import Wire.API.Routes.Public.Galley.Responses (RemoveFromConversationError (..)) | ||
|
|
||
| testObject_LeaveConversationResponse1 :: LeaveConversationResponse | ||
| testObject_LeaveConversationResponse1 = LeaveConversationResponse $ Right () | ||
|
|
||
| testObject_LeaveConversationResponse2 :: LeaveConversationResponse | ||
| testObject_LeaveConversationResponse2 = LeaveConversationResponse $ Left RemoveFromConversationErrorRemovalNotAllowed | ||
|
|
||
| testObject_LeaveConversationResponse3 :: LeaveConversationResponse | ||
| testObject_LeaveConversationResponse3 = LeaveConversationResponse $ Left RemoveFromConversationErrorManagedConvNotAllowed | ||
|
|
||
| testObject_LeaveConversationResponse4 :: LeaveConversationResponse | ||
| testObject_LeaveConversationResponse4 = LeaveConversationResponse $ Left RemoveFromConversationErrorNotFound | ||
|
|
||
| testObject_LeaveConversationResponse5 :: LeaveConversationResponse | ||
| testObject_LeaveConversationResponse5 = LeaveConversationResponse $ Left RemoveFromConversationErrorCustomRolesNotSupported | ||
|
|
||
| testObject_LeaveConversationResponse6 :: LeaveConversationResponse | ||
| testObject_LeaveConversationResponse6 = LeaveConversationResponse $ Left RemoveFromConversationErrorSelfConv | ||
|
|
||
| testObject_LeaveConversationResponse7 :: LeaveConversationResponse | ||
| testObject_LeaveConversationResponse7 = LeaveConversationResponse $ Left RemoveFromConversationErrorOne2OneConv | ||
|
|
||
| testObject_LeaveConversationResponse8 :: LeaveConversationResponse | ||
| testObject_LeaveConversationResponse8 = LeaveConversationResponse $ Left RemoveFromConversationErrorConnectConv | ||
|
|
||
| testObject_LeaveConversationResponse9 :: LeaveConversationResponse | ||
| testObject_LeaveConversationResponse9 = LeaveConversationResponse $ Left RemoveFromConversationErrorUnchanged |
31 changes: 31 additions & 0 deletions
31
libs/wire-api-federation/test/golden/testObject_ConversationMemberUpdate1.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| { | ||
| "orig_user_id": { | ||
| "domain": "golden.example.com", | ||
| "id": "00000000-0000-0000-0000-000100000007" | ||
| }, | ||
| "already_present_users": [], | ||
| "time": "1864-04-12T12:22:43.673Z", | ||
| "action": { | ||
| "tag": "ConversationMembersActionAdd", | ||
| "contents": [ | ||
| [ | ||
| { | ||
| "domain": "golden.example.com", | ||
| "id": "00000000-0000-0000-0000-000100004007" | ||
| }, | ||
| "wire_member" | ||
| ], | ||
| [ | ||
| { | ||
| "domain": "golden2.example.com", | ||
| "id": "00000000-0000-0000-0000-000100005007" | ||
| }, | ||
| "wire_admin" | ||
| ] | ||
| ] | ||
| }, | ||
| "conv_id": { | ||
| "domain": "golden2.example.com", | ||
| "id": "00000000-0000-0000-0000-000100000006" | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.