Skip to content

Commit

Permalink
Send conversation update to all remote backends
Browse files Browse the repository at this point in the history
Before this change, only backends of new users (including local ones)
were notified of a conversation update.
  • Loading branch information
pcapriotti committed Jun 7, 2021
1 parent d5669a3 commit bdf3660
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
10 changes: 5 additions & 5 deletions services/galley/src/Galley/API/Update.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ import Data.Code
import Data.Id
import Data.Json.Util (toUTCTimeMillis)
import Data.LegalHold (UserLegalHoldStatus (UserLegalHoldNoConsent), defUserLegalHoldStatus)
import Data.List.Extra (nubOrdOn)
import Data.List.Extra (nubOrd, nubOrdOn)
import Data.List1
import qualified Data.Map.Strict as Map
import Data.Misc (FutureWork (..))
Expand Down Expand Up @@ -892,16 +892,16 @@ addToConversation (bots, lothers) rothers (usr, usrRole) conn locals remotes c =
now <- liftIO getCurrentTime
localDomain <- viewFederationDomain
(e, lmm, rmm) <- Data.addMembersWithRole localDomain now (Data.convId c) (usr, usrRole) mems
let others = catMembers localDomain lothers rothers
mm = catMembers localDomain lmm rmm
let mm = catMembers localDomain lmm rmm
qcnv = Qualified (Data.convId c) localDomain
qusr = Qualified usr localDomain
-- FUTUREWORK: parallelise federated requests
traverse_ (uncurry (updateRemoteConversations now mm qusr qcnv))
. Map.assocs
. partitionQualified
. map fst
$ others
. nubOrd
. map (unTagged . rmId)
$ rmm <> rothers
let allMembers = nubOrdOn memId (lmm <> lothers)
for_ (newPush ListComplete usr (ConvEvent e) (recipient <$> allMembers)) $ \p ->
push1 $ p & pushConn ?~ conn
Expand Down
11 changes: 9 additions & 2 deletions services/galley/test/integration/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import Data.Aeson hiding (json)
import qualified Data.ByteString as BS
import Data.ByteString.Conversion
import qualified Data.Code as Code
import Data.Domain (Domain (Domain))
import Data.Domain (Domain (Domain), domainText)
import Data.Id
import Data.List.NonEmpty (NonEmpty (..))
import Data.List1
Expand Down Expand Up @@ -1015,12 +1015,19 @@ testAddRemoteMember = do
let qconvId = Qualified convId localDomain
opts <- view tsGConf
g <- view tsGalley
(resp, _) <-
(resp, reqs) <-
withTempMockFederator
opts
remoteDomain
(respond remoteBob)
(postQualifiedMembers' g alice (remoteBob :| []) convId)
liftIO $ do
map F.domain reqs @?= replicate 2 (domainText remoteDomain)
map (fmap F.path . F.request) reqs
@?= [ Just "/federation/get-users-by-ids",
Just "/federation/update-conversation-memberships"
]

e <- responseJsonUnsafe <$> (pure resp <!! const 200 === statusCode)
liftIO $ do
evtConv e @?= qconvId
Expand Down

0 comments on commit bdf3660

Please sign in to comment.