@@ -108,29 +108,49 @@ updateTeamCollaboratorImpl ::
108
108
updateTeamCollaboratorImpl zUser user team perms = do
109
109
guardPermission (tUnqualified zUser) team TeamMember. UpdateTeamCollaborator InsufficientRights
110
110
Store. updateTeamCollaborator user team perms
111
- when (Set. null $ Set. intersection (Set. fromList [CreateTeamConversation , ImplicitConnection ]) perms) $
112
- internalLeavingConversationsFrom team user
113
111
114
112
now <- get
115
- let event = newEvent team now (EdCollaboratorUpdate user $ Set. toList perms)
116
113
teamMembersList <- internalGetTeamAdmins team
117
114
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)
118
138
-- 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
134
154
135
155
internalRemoveTeamCollaboratorImpl ::
136
156
( Member Store. TeamCollaboratorsStore r
0 commit comments