From 6d390fc36d503c9dd3a3418afd50a51563d4b108 Mon Sep 17 00:00:00 2001 From: Paolo Capriotti Date: Fri, 28 Apr 2023 14:53:08 +0200 Subject: [PATCH] Remove LWT in planMLSClientRemoval --- services/galley/src/Galley/API/MLS/Message.hs | 4 ++-- .../Galley/Cassandra/Conversation/Members.hs | 17 ++++++++--------- services/galley/src/Galley/Cassandra/Queries.hs | 4 ++-- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/services/galley/src/Galley/API/MLS/Message.hs b/services/galley/src/Galley/API/MLS/Message.hs index 99f117cd48a..4f2ada95fda 100644 --- a/services/galley/src/Galley/API/MLS/Message.hs +++ b/services/galley/src/Galley/API/MLS/Message.hs @@ -73,8 +73,8 @@ import Wire.API.MLS.SubConversation -- TODO: -- [ ] restore deleted MLS unit tests --- [ ] pass groupId and epoch to processProposal instead of the whole IncomingMessage --- [ ] remove LWT in planMLSClientRemoval +-- [x] pass groupId and epoch to processProposal instead of the whole IncomingMessage +-- [x] remove LWT in planMLSClientRemoval -- [ ] restore unsupported proposal integration test -- FUTUREWORK diff --git a/services/galley/src/Galley/Cassandra/Conversation/Members.hs b/services/galley/src/Galley/Cassandra/Conversation/Members.hs index 97bcb237e34..da67f5e52f0 100644 --- a/services/galley/src/Galley/Cassandra/Conversation/Members.hs +++ b/services/galley/src/Galley/Cassandra/Conversation/Members.hs @@ -350,16 +350,15 @@ addMLSClients groupId (Qualified usr domain) cs = retry x5 . batch $ do for_ cs $ \(c, idx) -> addPrepQuery Cql.addMLSClient (groupId, domain, usr, c, fromIntegral idx) --- TODO Could (and should) we use batch instead? planMLSClientRemoval :: Foldable f => GroupId -> f ClientIdentity -> Client () -planMLSClientRemoval groupId cids = for_ cids $ \cid -> do - retry x5 $ - trans - Cql.planMLSClientRemoval - ( params - LocalQuorum - (groupId, ciDomain cid, ciUser cid, ciClient cid) - ) +planMLSClientRemoval groupId cids = + retry x5 . batch $ do + setType BatchLogged + setConsistency LocalQuorum + for_ cids $ \cid -> do + addPrepQuery + Cql.planMLSClientRemoval + (groupId, ciDomain cid, ciUser cid, ciClient cid) removeMLSClients :: GroupId -> Qualified UserId -> Set.Set ClientId -> Client () removeMLSClients groupId (Qualified usr domain) cs = retry x5 . batch $ do diff --git a/services/galley/src/Galley/Cassandra/Queries.hs b/services/galley/src/Galley/Cassandra/Queries.hs index ad4e989f29d..7c632334a7a 100644 --- a/services/galley/src/Galley/Cassandra/Queries.hs +++ b/services/galley/src/Galley/Cassandra/Queries.hs @@ -465,8 +465,8 @@ rmMemberClient c = addMLSClient :: PrepQuery W (GroupId, Domain, UserId, ClientId, Int32) () addMLSClient = "insert into mls_group_member_client (group_id, user_domain, user, client, leaf_node_index, removal_pending) values (?, ?, ?, ?, ?, false)" -planMLSClientRemoval :: PrepQuery W (GroupId, Domain, UserId, ClientId) Row -planMLSClientRemoval = "update mls_group_member_client set removal_pending = true where group_id = ? and user_domain = ? and user = ? and client = ? if exists" +planMLSClientRemoval :: PrepQuery W (GroupId, Domain, UserId, ClientId) () +planMLSClientRemoval = "update mls_group_member_client set removal_pending = true where group_id = ? and user_domain = ? and user = ? and client = ?" removeMLSClient :: PrepQuery W (GroupId, Domain, UserId, ClientId) () removeMLSClient = "delete from mls_group_member_client where group_id = ? and user_domain = ? and user = ? and client = ?"