Skip to content
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

extend on-new-remote-conversation by the subconv ID #2997

Merged
merged 22 commits into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b573376
extend on-new-remote-conversation by the subconv ID
stefanwire Jan 17, 2023
99fbb33
invoke on-new-remote-conversation in addMembers
stefanwire Jan 17, 2023
2983e30
add end2end test for messages in a subconversation
stefanwire Jan 19, 2023
e18d32b
Notify new backends about existing subconvs
pcapriotti Jan 20, 2023
6f0d66d
Add client field to federated MLS messages
pcapriotti Jan 23, 2023
581988b
Use sender client for federated messages
pcapriotti Jan 24, 2023
a11d6a6
Test remote user joining a local subconversation
pcapriotti Jan 26, 2023
6a6a79d
fix deserialisation of subgroups in e2e tests
stefanwire Jan 26, 2023
b371129
add client header to requests in e2e tests
stefanwire Jan 26, 2023
1636112
fix comments in e2e test
stefanwire Jan 26, 2023
c583532
abstract sendCommitBundle in e2e tests
stefanwire Jan 26, 2023
55dbfd7
Test joining remote subconversation
pcapriotti Jan 30, 2023
8328f15
Test onrc when a new backend joins a conversation
pcapriotti Jan 30, 2023
0aa072d
Call onrc when a subconversation is reset
pcapriotti Jan 30, 2023
cbae292
Test onrc call when resetting a subconversation
pcapriotti Jan 30, 2023
2c2c866
Split on-new-remote-conversation into 2 endpoints
pcapriotti Jan 30, 2023
048bf48
lint: remove redundant brackets
stefanwire Jan 30, 2023
4701626
Fix assertions of RPCs
pcapriotti Jan 31, 2023
68c79d9
add changelog entry
stefanwire Jan 31, 2023
785edc1
Update services/galley/test/integration/API/MLS.hs
stefanwire Feb 1, 2023
b1f4fb2
Do not call onrsc unless the subconv is new
pcapriotti Feb 1, 2023
2f0e92d
Use bucketRemote
pcapriotti Feb 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog.d/6-federation/on-new-remote-subconversation
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Split federation endpoint into on-new-remote-conversation and on-new-remote-subconversation
Call on-new-remote-subconversation when a new subconversation is created
Call on-new-remote-subconversation for all existing subconversations when a new backend gets involved
Call on-new-remote-subconversation when a subconversation is reset
30 changes: 26 additions & 4 deletions libs/wire-api-federation/src/Wire/API/Federation/API/Galley.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,16 @@ type GalleyApi =
-- This endpoint is called the first time a user from this backend is
-- added to a remote conversation.
:<|> FedEndpoint "on-new-remote-conversation" NewRemoteConversation EmptyResponse
:<|> FedEndpoint "on-new-remote-subconversation" NewRemoteSubConversation EmptyResponse
:<|> FedEndpoint "get-conversations" GetConversationsRequest GetConversationsResponse
-- used by the backend that owns a conversation to inform this backend of
-- changes to the conversation
:<|> FedEndpoint "on-conversation-updated" ConversationUpdate ()
:<|> FedEndpointWithMods
'[ MakesFederatedCall 'Galley "on-conversation-updated",
MakesFederatedCall 'Galley "on-mls-message-sent",
MakesFederatedCall 'Galley "on-new-remote-conversation"
MakesFederatedCall 'Galley "on-new-remote-conversation",
MakesFederatedCall 'Galley "on-new-remote-subconversation"
]
"leave-conversation"
LeaveConversationRequest
Expand All @@ -83,15 +85,17 @@ type GalleyApi =
:<|> FedEndpointWithMods
'[ MakesFederatedCall 'Galley "on-mls-message-sent",
MakesFederatedCall 'Galley "on-conversation-updated",
MakesFederatedCall 'Galley "on-new-remote-conversation"
MakesFederatedCall 'Galley "on-new-remote-conversation",
MakesFederatedCall 'Galley "on-new-remote-subconversation"
]
"on-user-deleted-conversations"
UserDeletedConversationsNotification
EmptyResponse
:<|> FedEndpointWithMods
'[ MakesFederatedCall 'Galley "on-conversation-updated",
MakesFederatedCall 'Galley "on-mls-message-sent",
MakesFederatedCall 'Galley "on-new-remote-conversation"
MakesFederatedCall 'Galley "on-new-remote-conversation",
MakesFederatedCall 'Galley "on-new-remote-subconversation"
]
"update-conversation"
ConversationUpdateRequest
Expand All @@ -102,6 +106,7 @@ type GalleyApi =
'[ MakesFederatedCall 'Galley "on-conversation-updated",
MakesFederatedCall 'Galley "on-mls-message-sent",
MakesFederatedCall 'Galley "on-new-remote-conversation",
MakesFederatedCall 'Galley "on-new-remote-subconversation",
MakesFederatedCall 'Galley "send-mls-message",
MakesFederatedCall 'Brig "get-mls-clients"
]
Expand All @@ -113,6 +118,7 @@ type GalleyApi =
MakesFederatedCall 'Galley "on-conversation-updated",
MakesFederatedCall 'Galley "on-mls-message-sent",
MakesFederatedCall 'Galley "on-new-remote-conversation",
MakesFederatedCall 'Galley "on-new-remote-subconversation",
MakesFederatedCall 'Galley "send-mls-commit-bundle",
MakesFederatedCall 'Brig "get-mls-clients"
]
Expand All @@ -128,7 +134,11 @@ type GalleyApi =
EmptyResponse
:<|> FedEndpoint "on-typing-indicator-updated" TypingDataUpdateRequest EmptyResponse
:<|> FedEndpoint "get-sub-conversation" GetSubConversationsRequest GetSubConversationsResponse
:<|> FedEndpoint "delete-sub-conversation" DeleteSubConversationRequest DeleteSubConversationResponse
:<|> FedEndpointWithMods
'[MakesFederatedCall 'Galley "on-new-remote-subconversation"]
"delete-sub-conversation"
DeleteSubConversationRequest
DeleteSubConversationResponse

data TypingDataUpdateRequest = TypingDataUpdateRequest
{ tdurTypingStatus :: TypingStatus,
Expand Down Expand Up @@ -226,6 +236,17 @@ data NewRemoteConversation = NewRemoteConversation
deriving stock (Eq, Show, Generic)
deriving (ToJSON, FromJSON) via (CustomEncoded NewRemoteConversation)

data NewRemoteSubConversation = NewRemoteSubConversation
{ -- | The ID of the parent conversation
nrscConvId :: ConvId,
-- | The subconversation ID
nrscSubConvId :: SubConvId,
-- | MLS data
nrscMlsData :: ConversationMLSData
}
deriving stock (Eq, Show, Generic)
deriving (ToJSON, FromJSON) via (CustomEncoded NewRemoteSubConversation)

data ConversationUpdate = ConversationUpdate
{ cuTime :: UTCTime,
cuOrigUserId :: Qualified UserId,
Expand Down Expand Up @@ -325,6 +346,7 @@ data MLSMessageSendRequest = MLSMessageSendRequest
-- | Sender is assumed to be owned by the origin domain, this allows us to
-- protect against spoofing attacks
mmsrSender :: UserId,
mmsrSenderClient :: ClientId,
mmsrRawMessage :: Base64ByteString
}
deriving stock (Eq, Show, Generic)
Expand Down
52 changes: 28 additions & 24 deletions libs/wire-api/src/Wire/API/Conversation/Protocol.hs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,34 @@ data ConversationMLSData = ConversationMLSData
}
deriving stock (Eq, Show, Generic)
deriving (Arbitrary) via GenericUniform ConversationMLSData
deriving (ToJSON, FromJSON) via Schema ConversationMLSData

mlsDataSchema :: ObjectSchema SwaggerDoc ConversationMLSData
mlsDataSchema =
ConversationMLSData
<$> cnvmlsGroupId
.= fieldWithDocModifier
"group_id"
(description ?~ "An MLS group identifier (at most 256 bytes long)")
schema
<*> cnvmlsEpoch
.= fieldWithDocModifier
"epoch"
(description ?~ "The epoch number of the corresponding MLS group")
schema
<*> cnvmlsEpochTimestamp
.= fieldWithDocModifier
"epoch_timestamp"
(description ?~ "The timestamp of the epoch number")
schemaEpochTimestamp
<*> cnvmlsCipherSuite
.= fieldWithDocModifier
"cipher_suite"
(description ?~ "The cipher suite of the corresponding MLS group")
schema

instance ToSchema ConversationMLSData where
schema = object "ConversationMLSData" mlsDataSchema

-- | Conversation protocol and protocol-specific data.
data Protocol
Expand Down Expand Up @@ -116,27 +144,3 @@ deriving via (Schema Protocol) instance ToJSON Protocol
protocolDataSchema :: ProtocolTag -> ObjectSchema SwaggerDoc Protocol
protocolDataSchema ProtocolProteusTag = tag _ProtocolProteus (pure ())
protocolDataSchema ProtocolMLSTag = tag _ProtocolMLS mlsDataSchema

mlsDataSchema :: ObjectSchema SwaggerDoc ConversationMLSData
mlsDataSchema =
ConversationMLSData
<$> cnvmlsGroupId
.= fieldWithDocModifier
"group_id"
(description ?~ "An MLS group identifier (at most 256 bytes long)")
schema
<*> cnvmlsEpoch
.= fieldWithDocModifier
"epoch"
(description ?~ "The epoch number of the corresponding MLS group")
schema
<*> cnvmlsEpochTimestamp
.= fieldWithDocModifier
"epoch_timestamp"
(description ?~ "The timestamp of the epoch number")
schemaEpochTimestamp
<*> cnvmlsCipherSuite
.= fieldWithDocModifier
"cipher_suite"
(description ?~ "The cipher suite of the corresponding MLS group")
schema
21 changes: 21 additions & 0 deletions libs/wire-api/src/Wire/API/Routes/Public/Galley/Conversation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,8 @@ type ConversationAPI =
"delete-subconversation"
( Summary "Delete an MLS subconversation"
:> MakesFederatedCall 'Galley "delete-sub-conversation"
:> MakesFederatedCall 'Galley "on-new-remote-conversation"
:> MakesFederatedCall 'Galley "on-new-remote-subconversation"
:> CanThrow 'ConvAccessDenied
:> CanThrow 'ConvNotFound
:> CanThrow 'MLSNotEnabled
Expand Down Expand Up @@ -513,6 +515,7 @@ type ConversationAPI =
:> MakesFederatedCall 'Galley "on-conversation-updated"
:> MakesFederatedCall 'Galley "on-mls-message-sent"
:> MakesFederatedCall 'Galley "on-new-remote-conversation"
:> MakesFederatedCall 'Galley "on-new-remote-subconversation"
:> Until 'V2
:> CanThrow ('ActionDenied 'AddConversationMember)
:> CanThrow ('ActionDenied 'LeaveConversation)
Expand All @@ -537,6 +540,7 @@ type ConversationAPI =
:> MakesFederatedCall 'Galley "on-conversation-updated"
:> MakesFederatedCall 'Galley "on-mls-message-sent"
:> MakesFederatedCall 'Galley "on-new-remote-conversation"
:> MakesFederatedCall 'Galley "on-new-remote-subconversation"
:> Until 'V2
:> CanThrow ('ActionDenied 'AddConversationMember)
:> CanThrow ('ActionDenied 'LeaveConversation)
Expand All @@ -562,6 +566,7 @@ type ConversationAPI =
:> MakesFederatedCall 'Galley "on-conversation-updated"
:> MakesFederatedCall 'Galley "on-mls-message-sent"
:> MakesFederatedCall 'Galley "on-new-remote-conversation"
:> MakesFederatedCall 'Galley "on-new-remote-subconversation"
:> From 'V2
:> CanThrow ('ActionDenied 'AddConversationMember)
:> CanThrow ('ActionDenied 'LeaveConversation)
Expand All @@ -587,6 +592,7 @@ type ConversationAPI =
( Summary "Join a conversation by its ID (if link access enabled)"
:> MakesFederatedCall 'Galley "on-conversation-updated"
:> MakesFederatedCall 'Galley "on-new-remote-conversation"
:> MakesFederatedCall 'Galley "on-new-remote-subconversation"
:> CanThrow 'ConvAccessDenied
:> CanThrow 'ConvNotFound
:> CanThrow 'InvalidOperation
Expand All @@ -609,6 +615,7 @@ type ConversationAPI =
\Note that this is currently inconsistent (for backwards compatibility reasons) with `POST /conversations/code-check` which responds with 404 CodeNotFound if guest links are disabled."
:> MakesFederatedCall 'Galley "on-conversation-updated"
:> MakesFederatedCall 'Galley "on-new-remote-conversation"
:> MakesFederatedCall 'Galley "on-new-remote-subconversation"
:> CanThrow 'CodeNotFound
:> CanThrow 'ConvAccessDenied
:> CanThrow 'ConvNotFound
Expand Down Expand Up @@ -739,6 +746,7 @@ type ConversationAPI =
:> MakesFederatedCall 'Galley "on-conversation-updated"
:> MakesFederatedCall 'Galley "on-mls-message-sent"
:> MakesFederatedCall 'Galley "on-new-remote-conversation"
:> MakesFederatedCall 'Galley "on-new-remote-subconversation"
:> Until 'V2
:> ZLocalUser
:> ZConn
Expand All @@ -760,6 +768,7 @@ type ConversationAPI =
:> MakesFederatedCall 'Galley "on-conversation-updated"
:> MakesFederatedCall 'Galley "on-mls-message-sent"
:> MakesFederatedCall 'Galley "on-new-remote-conversation"
:> MakesFederatedCall 'Galley "on-new-remote-subconversation"
:> ZLocalUser
:> ZConn
:> CanThrow ('ActionDenied 'RemoveConversationMember)
Expand All @@ -779,6 +788,7 @@ type ConversationAPI =
:> Description "Use `PUT /conversations/:cnv_domain/:cnv/members/:usr_domain/:usr` instead"
:> MakesFederatedCall 'Galley "on-conversation-updated"
:> MakesFederatedCall 'Galley "on-new-remote-conversation"
:> MakesFederatedCall 'Galley "on-new-remote-subconversation"
:> ZLocalUser
:> ZConn
:> CanThrow 'ConvNotFound
Expand All @@ -803,6 +813,7 @@ type ConversationAPI =
:> Description "**Note**: at least one field has to be provided."
:> MakesFederatedCall 'Galley "on-conversation-updated"
:> MakesFederatedCall 'Galley "on-new-remote-conversation"
:> MakesFederatedCall 'Galley "on-new-remote-subconversation"
:> ZLocalUser
:> ZConn
:> CanThrow 'ConvNotFound
Expand All @@ -829,6 +840,7 @@ type ConversationAPI =
:> Description "Use `/conversations/:domain/:conv/name` instead."
:> MakesFederatedCall 'Galley "on-conversation-updated"
:> MakesFederatedCall 'Galley "on-new-remote-conversation"
:> MakesFederatedCall 'Galley "on-new-remote-subconversation"
:> CanThrow ('ActionDenied 'ModifyConversationName)
:> CanThrow 'ConvNotFound
:> CanThrow 'InvalidOperation
Expand All @@ -849,6 +861,7 @@ type ConversationAPI =
:> Description "Use `/conversations/:domain/:conv/name` instead."
:> MakesFederatedCall 'Galley "on-conversation-updated"
:> MakesFederatedCall 'Galley "on-new-remote-conversation"
:> MakesFederatedCall 'Galley "on-new-remote-subconversation"
:> CanThrow ('ActionDenied 'ModifyConversationName)
:> CanThrow 'ConvNotFound
:> CanThrow 'InvalidOperation
Expand All @@ -869,6 +882,7 @@ type ConversationAPI =
( Summary "Update conversation name"
:> MakesFederatedCall 'Galley "on-conversation-updated"
:> MakesFederatedCall 'Galley "on-new-remote-conversation"
:> MakesFederatedCall 'Galley "on-new-remote-subconversation"
:> CanThrow ('ActionDenied 'ModifyConversationName)
:> CanThrow 'ConvNotFound
:> CanThrow 'InvalidOperation
Expand All @@ -892,6 +906,7 @@ type ConversationAPI =
:> Description "Use `/conversations/:domain/:cnv/message-timer` instead."
:> MakesFederatedCall 'Galley "on-conversation-updated"
:> MakesFederatedCall 'Galley "on-new-remote-conversation"
:> MakesFederatedCall 'Galley "on-new-remote-subconversation"
:> ZLocalUser
:> ZConn
:> CanThrow ('ActionDenied 'ModifyConversationMessageTimer)
Expand All @@ -913,6 +928,7 @@ type ConversationAPI =
( Summary "Update the message timer for a conversation"
:> MakesFederatedCall 'Galley "on-conversation-updated"
:> MakesFederatedCall 'Galley "on-new-remote-conversation"
:> MakesFederatedCall 'Galley "on-new-remote-subconversation"
:> ZLocalUser
:> ZConn
:> CanThrow ('ActionDenied 'ModifyConversationMessageTimer)
Expand All @@ -937,6 +953,7 @@ type ConversationAPI =
:> Description "Use `PUT /conversations/:domain/:cnv/receipt-mode` instead."
:> MakesFederatedCall 'Galley "on-conversation-updated"
:> MakesFederatedCall 'Galley "on-new-remote-conversation"
:> MakesFederatedCall 'Galley "on-new-remote-subconversation"
:> MakesFederatedCall 'Galley "update-conversation"
:> ZLocalUser
:> ZConn
Expand All @@ -959,6 +976,7 @@ type ConversationAPI =
( Summary "Update receipt mode for a conversation"
:> MakesFederatedCall 'Galley "on-conversation-updated"
:> MakesFederatedCall 'Galley "on-new-remote-conversation"
:> MakesFederatedCall 'Galley "on-new-remote-subconversation"
:> MakesFederatedCall 'Galley "update-conversation"
:> ZLocalUser
:> ZConn
Expand All @@ -985,6 +1003,7 @@ type ConversationAPI =
:> MakesFederatedCall 'Galley "on-conversation-updated"
:> MakesFederatedCall 'Galley "on-mls-message-sent"
:> MakesFederatedCall 'Galley "on-new-remote-conversation"
:> MakesFederatedCall 'Galley "on-new-remote-subconversation"
:> Until 'V3
:> Description "Use PUT `/conversations/:domain/:cnv/access` instead."
:> ZLocalUser
Expand All @@ -1011,6 +1030,7 @@ type ConversationAPI =
:> MakesFederatedCall 'Galley "on-conversation-updated"
:> MakesFederatedCall 'Galley "on-mls-message-sent"
:> MakesFederatedCall 'Galley "on-new-remote-conversation"
:> MakesFederatedCall 'Galley "on-new-remote-subconversation"
:> Until 'V3
:> ZLocalUser
:> ZConn
Expand All @@ -1036,6 +1056,7 @@ type ConversationAPI =
:> MakesFederatedCall 'Galley "on-conversation-updated"
:> MakesFederatedCall 'Galley "on-mls-message-sent"
:> MakesFederatedCall 'Galley "on-new-remote-conversation"
:> MakesFederatedCall 'Galley "on-new-remote-subconversation"
:> From 'V3
:> ZLocalUser
:> ZConn
Expand Down
3 changes: 2 additions & 1 deletion libs/wire-api/src/Wire/API/Routes/Public/Galley/Feature.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ type FeatureAPI =
:<|> FeatureStatusPut
'[ MakesFederatedCall 'Galley "on-conversation-updated",
MakesFederatedCall 'Galley "on-mls-message-sent",
MakesFederatedCall 'Galley "on-new-remote-conversation"
MakesFederatedCall 'Galley "on-new-remote-conversation",
MakesFederatedCall 'Galley "on-new-remote-subconversation"
]
'( 'ActionDenied 'RemoveConversationMember,
'( AuthenticationError,
Expand Down
5 changes: 5 additions & 0 deletions libs/wire-api/src/Wire/API/Routes/Public/Galley/LegalHold.hs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ type LegalHoldAPI =
:> MakesFederatedCall 'Galley "on-conversation-updated"
:> MakesFederatedCall 'Galley "on-mls-message-sent"
:> MakesFederatedCall 'Galley "on-new-remote-conversation"
:> MakesFederatedCall 'Galley "on-new-remote-subconversation"
:> CanThrow AuthenticationError
:> CanThrow OperationDenied
:> CanThrow 'NotATeamMember
Expand Down Expand Up @@ -105,6 +106,7 @@ type LegalHoldAPI =
:> MakesFederatedCall 'Galley "on-conversation-updated"
:> MakesFederatedCall 'Galley "on-mls-message-sent"
:> MakesFederatedCall 'Galley "on-new-remote-conversation"
:> MakesFederatedCall 'Galley "on-new-remote-subconversation"
:> CanThrow ('ActionDenied 'RemoveConversationMember)
:> CanThrow 'InvalidOperation
:> CanThrow 'TeamMemberNotFound
Expand All @@ -123,6 +125,7 @@ type LegalHoldAPI =
:> MakesFederatedCall 'Galley "on-conversation-updated"
:> MakesFederatedCall 'Galley "on-mls-message-sent"
:> MakesFederatedCall 'Galley "on-new-remote-conversation"
:> MakesFederatedCall 'Galley "on-new-remote-subconversation"
:> CanThrow ('ActionDenied 'RemoveConversationMember)
:> CanThrow 'NotATeamMember
:> CanThrow OperationDenied
Expand Down Expand Up @@ -154,6 +157,7 @@ type LegalHoldAPI =
:> MakesFederatedCall 'Galley "on-conversation-updated"
:> MakesFederatedCall 'Galley "on-mls-message-sent"
:> MakesFederatedCall 'Galley "on-new-remote-conversation"
:> MakesFederatedCall 'Galley "on-new-remote-subconversation"
:> CanThrow AuthenticationError
:> CanThrow ('ActionDenied 'RemoveConversationMember)
:> CanThrow 'NotATeamMember
Expand Down Expand Up @@ -183,6 +187,7 @@ type LegalHoldAPI =
:> MakesFederatedCall 'Galley "on-conversation-updated"
:> MakesFederatedCall 'Galley "on-mls-message-sent"
:> MakesFederatedCall 'Galley "on-new-remote-conversation"
:> MakesFederatedCall 'Galley "on-new-remote-subconversation"
:> CanThrow AuthenticationError
:> CanThrow 'AccessDenied
:> CanThrow ('ActionDenied 'RemoveConversationMember)
Expand Down
Loading