Skip to content

Commit 6277070

Browse files
committed
fix: add perform-ability to leave
1 parent 4645e66 commit 6277070

File tree

1 file changed

+38
-18
lines changed
  • libs/wire-subsystems/src/Wire/TeamCollaboratorsSubsystem

1 file changed

+38
-18
lines changed

libs/wire-subsystems/src/Wire/TeamCollaboratorsSubsystem/Interpreter.hs

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -108,29 +108,49 @@ updateTeamCollaboratorImpl ::
108108
updateTeamCollaboratorImpl zUser user team perms = do
109109
guardPermission (tUnqualified zUser) team TeamMember.UpdateTeamCollaborator InsufficientRights
110110
Store.updateTeamCollaborator user team perms
111-
when (Set.null $ Set.intersection (Set.fromList [CreateTeamConversation, ImplicitConnection]) perms) $
112-
internalLeavingConversationsFrom team user
113111

114112
now <- get
115-
let event = newEvent team now (EdCollaboratorUpdate user $ Set.toList perms)
116113
teamMembersList <- internalGetTeamAdmins team
117114
let teamMembers :: [UserId] = view TeamMember.userId <$> (teamMembersList ^. TeamMember.teamMembers)
115+
116+
extraNotifications <-
117+
if Set.null $ Set.intersection (Set.fromList [CreateTeamConversation, ImplicitConnection]) perms
118+
then do
119+
leavingConversations <- internalLeaveConversationsFrom team user
120+
pure $
121+
leavingConversations.close <&> \convId ->
122+
def
123+
{ origin = Just (tUnqualified zUser),
124+
json = toJSONObject $ newEvent team now (EdConvDelete convId),
125+
recipients =
126+
( \uid ->
127+
Recipient
128+
{ recipientUserId = uid,
129+
recipientClients = Push.RecipientClientsAll
130+
}
131+
)
132+
<$> teamMembers,
133+
transient = False
134+
}
135+
else pure []
136+
137+
let event = newEvent team now (EdCollaboratorUpdate user $ Set.toList perms)
118138
-- TODO: Review the event's values
119-
pushNotifications
120-
[ def
121-
{ origin = Just (tUnqualified zUser),
122-
json = toJSONObject $ event,
123-
recipients =
124-
( \uid ->
125-
Recipient
126-
{ recipientUserId = uid,
127-
recipientClients = Push.RecipientClientsAll
128-
}
129-
)
130-
<$> teamMembers,
131-
transient = False
132-
}
133-
]
139+
pushNotifications $
140+
def
141+
{ origin = Just (tUnqualified zUser),
142+
json = toJSONObject $ event,
143+
recipients =
144+
( \uid ->
145+
Recipient
146+
{ recipientUserId = uid,
147+
recipientClients = Push.RecipientClientsAll
148+
}
149+
)
150+
<$> teamMembers,
151+
transient = False
152+
}
153+
: extraNotifications
134154

135155
internalRemoveTeamCollaboratorImpl ::
136156
( Member Store.TeamCollaboratorsStore r

0 commit comments

Comments
 (0)