Skip to content

Commit

Permalink
Revert "[FS-1148] Resilient member adding in presence of unreachable …
Browse files Browse the repository at this point in the history
…backends (1/2) (#3248)" (#3275)

This reverts commit 4a4ba8d.
  • Loading branch information
mdimjasevic authored May 9, 2023
1 parent 2231ca1 commit 3836eb0
Show file tree
Hide file tree
Showing 30 changed files with 294 additions and 677 deletions.
1 change: 0 additions & 1 deletion changelog.d/1-api-changes/mls-conv-add-across-federation

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/6-federation/failed-to-process

This file was deleted.

10 changes: 5 additions & 5 deletions libs/wire-api-federation/src/Wire/API/Federation/API/Galley.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ import Wire.API.Conversation.Typing
import Wire.API.Error.Galley
import Wire.API.Federation.API.Common
import Wire.API.Federation.Endpoint
import Wire.API.MLS.Message
import Wire.API.MLS.SubConversation
import Wire.API.MakesFederatedCall
import Wire.API.Message
import Wire.API.Routes.Public.Galley.Messaging
import Wire.API.Unreachable
import Wire.API.Util.Aeson (CustomEncoded (..))
import Wire.Arbitrary (Arbitrary, GenericUniform (..))

Expand Down Expand Up @@ -365,11 +365,11 @@ newtype MessageSendResponse = MessageSendResponse
)

newtype LeaveConversationResponse = LeaveConversationResponse
{leaveResponse :: Either RemoveFromConversationError FailedToProcess}
{leaveResponse :: Either RemoveFromConversationError ()}
deriving stock (Eq, Show)
deriving
(ToJSON, FromJSON)
via (Either (CustomEncoded RemoveFromConversationError) FailedToProcess)
via (Either (CustomEncoded RemoveFromConversationError) ())

type UserDeletedNotificationMaxConvs = 1000

Expand Down Expand Up @@ -398,7 +398,7 @@ data ConversationUpdateRequest = ConversationUpdateRequest

data ConversationUpdateResponse
= ConversationUpdateResponseError GalleyError
| ConversationUpdateResponseUpdate (ConversationUpdate, FailedToProcess)
| ConversationUpdateResponseUpdate ConversationUpdate
| ConversationUpdateResponseNoChanges
deriving stock (Eq, Show, Generic)
deriving
Expand All @@ -423,7 +423,7 @@ data MLSMessageResponse
= MLSMessageResponseError GalleyError
| MLSMessageResponseProtocolError Text
| MLSMessageResponseProposalFailure Wai.Error
| MLSMessageResponseUpdates [ConversationUpdate] FailedToProcess
| MLSMessageResponseUpdates [ConversationUpdate] UnreachableUsers
deriving stock (Eq, Show, Generic)
deriving (ToJSON, FromJSON) via (CustomEncoded MLSMessageResponse)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ spec =
testObjects
[ (MLSMessageSendingStatus.testObject_MLSMessageSendingStatus1, "testObject_MLSMessageSendingStatus1.json"),
(MLSMessageSendingStatus.testObject_MLSMessageSendingStatus2, "testObject_MLSMessageSendingStatus2.json"),
(MLSMessageSendingStatus.testObject_MLSMessageSendingStatus3, "testObject_MLSMessageSendingStatus3.json"),
(MLSMessageSendingStatus.testObject_MLSMessageSendingStatus4, "testObject_MLSMessageSendingStatus4.json"),
(MLSMessageSendingStatus.testObject_MLSMessageSendingStatus5, "testObject_MLSMessageSendingStatus5.json"),
(MLSMessageSendingStatus.testObject_MLSMessageSendingStatus6, "testObject_MLSMessageSendingStatus6.json")
(MLSMessageSendingStatus.testObject_MLSMessageSendingStatus3, "testObject_MLSMessageSendingStatus3.json")
]
testObjects [(LeaveConversationRequest.testObject_LeaveConversationRequest1, "testObject_LeaveConversationRequest1.json")]
testObjects
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import Imports
import Wire.API.Federation.API.Galley

testObject_LeaveConversationResponse1 :: LeaveConversationResponse
testObject_LeaveConversationResponse1 = LeaveConversationResponse $ Right mempty
testObject_LeaveConversationResponse1 = LeaveConversationResponse $ Right ()

testObject_LeaveConversationResponse2 :: LeaveConversationResponse
testObject_LeaveConversationResponse2 = LeaveConversationResponse $ Left RemoveFromConversationErrorRemovalNotAllowed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,65 +24,40 @@ import Data.Qualified
import qualified Data.UUID as UUID
import Imports
import Wire.API.MLS.Message
import Wire.API.Unreachable

testObject_MLSMessageSendingStatus1 :: MLSMessageSendingStatus
testObject_MLSMessageSendingStatus1 =
MLSMessageSendingStatus
{ mmssEvents = [],
mmssTime = toUTCTimeMillis (read "1864-04-12 12:22:43.673 UTC"),
mmssFailedToProcess = mempty
mmssUnreachableUsers = UnreachableUsers []
}

testObject_MLSMessageSendingStatus2 :: MLSMessageSendingStatus
testObject_MLSMessageSendingStatus2 =
MLSMessageSendingStatus
{ mmssEvents = [],
mmssTime = toUTCTimeMillis (read "2001-04-12 12:22:43.673 UTC"),
mmssFailedToProcess = failedToSend failed1
mmssUnreachableUsers = failed1
}

testObject_MLSMessageSendingStatus3 :: MLSMessageSendingStatus
testObject_MLSMessageSendingStatus3 =
MLSMessageSendingStatus
{ mmssEvents = [],
mmssTime = toUTCTimeMillis (read "1999-04-12 12:22:43.673 UTC"),
mmssFailedToProcess = failedToSend failed2
mmssUnreachableUsers = failed2
}

testObject_MLSMessageSendingStatus4 :: MLSMessageSendingStatus
testObject_MLSMessageSendingStatus4 =
MLSMessageSendingStatus
{ mmssEvents = [],
mmssTime = toUTCTimeMillis (read "2023-04-12 12:22:43.673 UTC"),
mmssFailedToProcess = failedToAdd failed1
}

testObject_MLSMessageSendingStatus5 :: MLSMessageSendingStatus
testObject_MLSMessageSendingStatus5 =
MLSMessageSendingStatus
{ mmssEvents = [],
mmssTime = toUTCTimeMillis (read "1901-04-12 12:22:43.673 UTC"),
mmssFailedToProcess = failedToRemove failed2
}

testObject_MLSMessageSendingStatus6 :: MLSMessageSendingStatus
testObject_MLSMessageSendingStatus6 =
MLSMessageSendingStatus
{ mmssEvents = [],
mmssTime = toUTCTimeMillis (read "1905-04-12 12:22:43.673 UTC"),
mmssFailedToProcess = failedToAdd failed1 <> failedToRemove failed2
}

failed1 :: [Qualified UserId]
failed1 :: UnreachableUsers
failed1 =
let domain = Domain "offline.example.com"
in [Qualified (Id . fromJust . UUID.fromString $ "00000000-0000-0000-0000-000200000008") domain]
in UnreachableUsers [Qualified (Id . fromJust . UUID.fromString $ "00000000-0000-0000-0000-000200000008") domain]

failed2 :: [Qualified UserId]
failed2 :: UnreachableUsers
failed2 =
let domain = Domain "golden.example.com"
in flip Qualified domain . Id . fromJust . UUID.fromString
<$> [ "00000000-0000-0000-0000-000200000008",
"00000000-0000-0000-0000-000100000007"
]
in UnreachableUsers
[ Qualified (Id . fromJust . UUID.fromString $ "00000000-0000-0000-0000-000200000008") domain,
Qualified (Id . fromJust . UUID.fromString $ "00000000-0000-0000-0000-000100000007") domain
]
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"Right": {}
"Right": []
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"events": [],
"time": "1864-04-12T12:22:43.673Z"
}
"events": [],
"time": "1864-04-12T12:22:43.673Z",
"failed_to_send": []
}

This file was deleted.

This file was deleted.

This file was deleted.

24 changes: 21 additions & 3 deletions libs/wire-api/src/Wire/API/MLS/Message.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module Wire.API.MLS.Message
MLSCipherTextSym0,
MLSMessageSendingStatus (..),
KnownFormatTag (..),
UnreachableUsers (..),
verifyMessageSignature,
mkSignedMessage,
)
Expand All @@ -49,8 +50,10 @@ import Data.Binary
import Data.Binary.Get
import Data.Binary.Put
import qualified Data.ByteArray as BA
import Data.Id
import Data.Json.Util
import Data.Kind
import Data.Qualified
import Data.Schema
import Data.Singletons.TH
import qualified Data.Swagger as S
Expand All @@ -64,7 +67,6 @@ import Wire.API.MLS.Group
import Wire.API.MLS.KeyPackage
import Wire.API.MLS.Proposal
import Wire.API.MLS.Serialisation
import Wire.API.Unreachable
import Wire.Arbitrary (GenericUniform (..))

data WireFormatTag = MLSPlainText | MLSCipherText
Expand Down Expand Up @@ -316,10 +318,22 @@ instance SerialiseMLS (MessagePayload 'MLSPlainText) where
-- so the next case is left as a stub
serialiseMLS _ = pure ()

newtype UnreachableUsers = UnreachableUsers {unreachableUsers :: [Qualified UserId]}
deriving stock (Eq, Show)
deriving (A.ToJSON, A.FromJSON, S.ToSchema) via Schema UnreachableUsers
deriving newtype (Semigroup, Monoid)

instance ToSchema UnreachableUsers where
schema =
named "UnreachableUsers" $
UnreachableUsers
<$> unreachableUsers
.= array schema

data MLSMessageSendingStatus = MLSMessageSendingStatus
{ mmssEvents :: [Event],
mmssTime :: UTCTimeMillis,
mmssFailedToProcess :: FailedToProcess
mmssUnreachableUsers :: UnreachableUsers
}
deriving (Eq, Show)
deriving (A.ToJSON, A.FromJSON, S.ToSchema) via Schema MLSMessageSendingStatus
Expand All @@ -338,7 +352,11 @@ instance ToSchema MLSMessageSendingStatus where
"time"
(description ?~ "The time of sending the message.")
schema
<*> mmssFailedToProcess .= failedToProcessObjectSchema
<*> mmssUnreachableUsers
.= fieldWithDocModifier
"failed_to_send"
(description ?~ "List of federated users who could not be reached and did not receive the message")
schema

verifyMessageSignature :: CipherSuiteTag -> Message 'MLSPlainText -> ByteString -> Bool
verifyMessageSignature cs msg pubkey =
Expand Down
Loading

0 comments on commit 3836eb0

Please sign in to comment.