@@ -80,26 +80,26 @@ import Wire.Util
8080data ProposalAction = ProposalAction
8181 { paAdd :: ClientMap (LeafIndex , Maybe KeyPackage ),
8282 paRemove :: ClientMap LeafIndex ,
83- historyClientAction :: Maybe HistoryClientAction
83+ paHistoryClientAdd :: Maybe (HistoryClientId , LeafIndex , Maybe KeyPackage ),
84+ paHistoryClientRemove :: Maybe (HistoryClientId , LeafIndex )
8485 }
8586 deriving (Show )
8687
87- data HistoryClientAction
88- = AddHistoryClient HistoryClientId
89- | RemoveHistoryClient HistoryClientId
90-
88+ -- TODO: (leif) check this
9189instance Semigroup ProposalAction where
92- ProposalAction add1 rem1 <> ProposalAction add2 rem2 =
93- ProposalAction (add1 <> add2) (rem1 <> rem2)
90+ ProposalAction add1 rem1 hadd1 hrem1 <> ProposalAction add2 rem2 hadd2 hrem2 =
91+ ProposalAction (add1 <> add2) (rem1 <> rem2) (hadd1 <|> hadd2) (hrem1 <|> hrem2)
9492
9593instance Monoid ProposalAction where
96- mempty = ProposalAction mempty mempty
94+ mempty = ProposalAction mempty mempty Nothing Nothing
9795
9896paAddClient :: GroupMember -> LeafIndex -> Maybe KeyPackage -> ProposalAction
99- paAddClient (RegularMember cid) idx kp = mempty {paAdd = cmSingleton cid (idx, kp)}
97+ paAddClient (RegularClient cid) idx kp = mempty {paAdd = cmSingleton cid (idx, kp)}
98+ paAddClient (HistoryClient hid) idx kp = mempty {paHistoryClientAdd = Just (hid, idx, kp)}
10099
101100paRemoveClient :: GroupMember -> LeafIndex -> ProposalAction
102- paRemoveClient cid idx = mempty {paRemove = cmSingleton cid idx}
101+ paRemoveClient (RegularClient cid) idx = mempty {paRemove = cmSingleton cid idx}
102+ paRemoveClient (HistoryClient hid) idx = mempty {paHistoryClientRemove = Just (hid, idx)}
103103
104104-- | This is used to sort proposals into the correct processing order, as defined by the spec
105105data ProposalProcessingStage
@@ -309,15 +309,18 @@ checkExternalProposalUser qusr prop = do
309309 loc
310310 ( \ lusr -> case prop of
311311 AddProposal kp -> do
312- ClientIdentity {ciUser, ciClient} <- getKeyPackageIdentity kp. value
313- -- requesting user must match key package owner
314- when (tUnqualified lusr /= ciUser) $ throwS @ 'MLSUnsupportedProposal
315- -- client referenced in key package must be one of the user's clients
316- UserClients {userClients} <- lookupClients [ciUser]
317- maybe
318- (throwS @ 'MLSUnsupportedProposal)
319- (flip when (throwS @ 'MLSUnsupportedProposal) . Set. null . Set. filter (== ciClient))
320- $ userClients Map. !? ciUser
312+ groupMember <- getKeyPackageIdentity kp. value
313+ case groupMember of
314+ RegularClient (ClientIdentity {ciUser, ciClient}) -> do
315+ -- requesting user must match key package owner
316+ when (tUnqualified lusr /= ciUser) $ throwS @ 'MLSUnsupportedProposal
317+ -- client referenced in key package must be one of the user's clients
318+ UserClients {userClients} <- lookupClients [ciUser]
319+ maybe
320+ (throwS @ 'MLSUnsupportedProposal)
321+ (flip when (throwS @ 'MLSUnsupportedProposal) . Set. null . Set. filter (== ciClient))
322+ $ userClients Map. !? ciUser
323+ HistoryClient _ -> pure ()
321324 _ -> throwS @ 'MLSUnsupportedProposal
322325 )
323326 (const $ pure () ) -- FUTUREWORK: check external proposals from remote backends
0 commit comments