Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions changelog.d/2-features/WPB-5936
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Send a `conversation.member-leave` event to team admins for each conversation the deleted team member used to be part of
3 changes: 2 additions & 1 deletion integration/test/Test/Conversation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -671,11 +671,12 @@ testDeleteTeamMember = do
conv <- postConversation alice nc >>= getJSON 201
withWebSockets [alice, amy, bob] $ \[wsAlice, wsAmy, wsBob] -> do
void $ deleteTeamMember team alice alex >>= getBody 202
assertConvLeaveNotif wsAmy alexId
do
n <- awaitMatch isTeamMemberLeaveNotif wsAlice
alexUId <- alex %. "id"
nPayload n %. "data.user" `shouldMatch` alexUId
assertConvLeaveNotif wsAmy alexId
assertConvLeaveNotif wsAlice alexId
do
bindResponse (getConversation bob conv) $ \resp -> do
resp.status `shouldMatchInt` 200
Expand Down
3 changes: 2 additions & 1 deletion services/brig/src/Brig/IO/Intra.hs
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,8 @@ upsertOne2OneConversation urequest = do
-------------------------------------------------------------------------------
-- User management

-- | Calls 'Galley.API.rmUserH', as well as gundeck and cargohold.
-- | Calls Galley's endpoint with the internal route ID "delete-user", as well
-- as gundeck and cargohold.
rmUser ::
( MonadReader Env m,
MonadIO m,
Expand Down
12 changes: 3 additions & 9 deletions services/galley/src/Galley/API/Teams.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ uncheckedDeleteTeamMember lusr zcon tid remove admins = do
pushMemberLeaveEvent now
E.deleteTeamMember tid remove
-- notify all conversation members not in this team.
removeFromConvsAndPushConvLeaveEvent lusr zcon tid remove admins
removeFromConvsAndPushConvLeaveEvent lusr zcon tid remove
where
-- notify team admins
pushMemberLeaveEvent :: UTCTime -> Sem r ()
Expand Down Expand Up @@ -1038,24 +1038,18 @@ removeFromConvsAndPushConvLeaveEvent ::
Maybe ConnId ->
TeamId ->
UserId ->
[UserId] ->
Sem r ()
removeFromConvsAndPushConvLeaveEvent lusr zcon tid remove admins = do
let teamAdmins = Set.fromList admins
removeFromConvsAndPushConvLeaveEvent lusr zcon tid remove = do
cc <- E.getTeamConversations tid
for_ cc $ \c ->
E.getConversation (c ^. conversationId) >>= \conv ->
for_ conv $ \dc ->
when (remove `isMember` Data.convLocalMembers dc) $ do
E.deleteMembers (c ^. conversationId) (UserList [remove] [])
let (bots, allLocUsers) = localBotsAndUsers (Data.convLocalMembers dc)
notAdmins =
foldMap
(\m -> guard (not (Conv.lmId m `Set.member` teamAdmins)) $> Conv.lmId m)
allLocUsers
targets =
BotsAndMembers
(Set.fromList notAdmins)
(Set.fromList $ Conv.lmId <$> allLocUsers)
(Set.fromList $ Conv.rmId <$> Data.convRemoteMembers dc)
(Set.fromList bots)
void $
Expand Down