Skip to content

Commit 1109dfc

Browse files
Add TeamId to conversation.delete event (#4618)
The field name is `team`. --------- Co-authored-by: Leif Battermann <[email protected]>
1 parent 7efdd4e commit 1109dfc

File tree

25 files changed

+120
-52
lines changed

25 files changed

+120
-52
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Add the `TeamId` to the payload of `conversation.delete` events. The field's
2+
path is `team`.

integration/test/Test/Cells.hs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,26 @@ testCellsCreationEvent = do
7777

7878
assertNoMessage q
7979

80+
testCellsDeletionEvent :: (HasCallStack) => App ()
81+
testCellsDeletionEvent = do
82+
-- start watcher before creating conversation
83+
q0 <- watchCellsEvents def
84+
(alice, tid, _) <- createTeam OwnDomain 1
85+
conv <- postConversation alice defProteus {team = Just tid, cells = True} >>= getJSON 201
86+
void $ deleteTeamConversation tid conv alice >>= assertSuccess
87+
88+
let q = q0 {filter = isConvDeleteNotif} :: QueueConsumer
89+
90+
event <- getMessage q %. "payload.0"
91+
event %. "type" `shouldMatch` "conversation.delete"
92+
event %. "conversation" `shouldMatch` (conv %. "qualified_id.id")
93+
event %. "qualified_conversation" `shouldMatch` (conv %. "qualified_id")
94+
event %. "qualified_from" `shouldMatch` (alice %. "qualified_id")
95+
event %. "from" `shouldMatch` (alice %. "qualified_id.id")
96+
event %. "team" `shouldMatch` tid
97+
98+
assertNoMessage q
99+
80100
testCellsCreationEventIsSentOnlyOnce :: (HasCallStack) => App ()
81101
testCellsCreationEventIsSentOnlyOnce = do
82102
-- start watcher before creating conversation

libs/wire-api/src/Wire/API/Conversation.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,7 @@ instance ToSchema NewOne2OneConv where
910910
<|> pure []
911911
)
912912
<*> name .= maybe_ (optField "name" schema)
913-
<*> team
913+
<*> (.team)
914914
.= maybe_
915915
( optFieldWithDocModifier
916916
"team"

libs/wire-api/src/Wire/API/Conversation/Action.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,10 @@ conversationActionToEvent ::
192192
Qualified UserId ->
193193
Qualified ConvId ->
194194
Maybe SubConvId ->
195+
Maybe TeamId ->
195196
ConversationAction tag ->
196197
Event
197-
conversationActionToEvent tag now quid qcnv subconv action =
198+
conversationActionToEvent tag now quid qcnv subconv tid action =
198199
let edata = case tag of
199200
SConversationJoinTag ->
200201
let ConversationJoin newMembers role joinType = action
@@ -215,7 +216,7 @@ conversationActionToEvent tag now quid qcnv subconv action =
215216
SConversationUpdateProtocolTag -> EdProtocolUpdate action
216217
SConversationUpdateAddPermissionTag -> EdAddPermissionUpdate action
217218
SConversationResetTag -> EdConvReset action.groupId
218-
in Event qcnv subconv quid now edata
219+
in Event qcnv subconv quid now tid edata
219220

220221
-- | Certain actions need to be performed at the level of the underlying
221222
-- protocol (MLS, mostly) before being applied to conversations. This function

libs/wire-api/src/Wire/API/Event/Conversation.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ data Event = Event
111111
evtSubConv :: Maybe SubConvId,
112112
evtFrom :: Qualified UserId,
113113
evtTime :: UTCTime,
114+
evtTeam :: Maybe TeamId,
114115
evtData :: EventData
115116
}
116117
deriving stock (Eq, Show, Generic)
@@ -126,6 +127,7 @@ instance Arbitrary Event where
126127
<*> arbitrary
127128
<*> arbitrary
128129
<*> (milli <$> arbitrary)
130+
<*> arbitrary
129131
<*> genEventData typ
130132
where
131133
milli = fromUTCTimeMillis . toUTCTimeMillis
@@ -472,8 +474,9 @@ eventObjectSchema =
472474
<* (qUnqualified . evtFrom) .= optional (field "from" schema)
473475
<*> evtFrom .= field "qualified_from" schema
474476
<*> (toUTCTimeMillis . evtTime) .= field "time" (fromUTCTimeMillis <$> schema)
477+
<*> evtTeam .= maybe_ (optField "team" schema)
475478
where
476-
mk (_, d) cid sconvid uid tm = Event cid sconvid uid tm d
479+
mk (_, d) cid sconvid uid tm tid = Event cid sconvid uid tm tid d
477480

478481
instance ToJSONObject Event where
479482
toJSONObject =

libs/wire-api/test/golden/Test/Wire/API/Golden/Generated/AddBotResponse_user.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ testObject_AddBotResponse_user_1 =
5656
Nothing
5757
(Qualified (Id (fromJust (UUID.fromString "00000004-0000-0004-0000-000400000004"))) (Domain "faraway.example.com"))
5858
(read "1864-05-12 19:20:22.286 UTC")
59+
Nothing
5960
(EdConvRename (ConversationRename {cupName = "6"}))
6061
}
6162

@@ -77,5 +78,6 @@ testObject_AddBotResponse_user_2 =
7778
Nothing
7879
(Qualified (Id (fromJust (UUID.fromString "00000004-0000-0000-0000-000300000001"))) (Domain "faraway.example.com"))
7980
(read "1864-05-08 19:02:58.6 UTC")
81+
Nothing
8082
(EdTyping StartedTyping)
8183
}

libs/wire-api/test/golden/Test/Wire/API/Golden/Generated/Event_conversation.hs

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ testObject_Event_conversation_1 =
4444
evtSubConv = Nothing,
4545
evtFrom = Qualified {qUnqualified = Id (fromJust (UUID.fromString "2126ea99-ca79-43ea-ad99-a59616468e8e")), qDomain = Domain {_domainText = "n8nl6tp.h5"}},
4646
evtTime = UTCTime {utctDay = ModifiedJulianDay 58119, utctDayTime = 0},
47-
evtData = EdConvCodeDelete
47+
evtData = EdConvCodeDelete,
48+
evtTeam = Nothing
4849
}
4950

5051
testObject_Event_conversation_2 :: Event
@@ -66,7 +67,8 @@ testObject_Event_conversation_2 =
6667
misHiddenRef = Nothing,
6768
misConvRoleName = Just roleNameWireAdmin
6869
}
69-
)
70+
),
71+
evtTeam = Nothing
7072
}
7173

7274
testObject_Event_conversation_3 :: Event
@@ -86,7 +88,8 @@ testObject_Event_conversation_3 =
8688
}
8789
)
8890
False
89-
)
91+
),
92+
evtTeam = Nothing
9093
}
9194

9295
testObject_Event_conversation_4 :: Event
@@ -96,7 +99,8 @@ testObject_Event_conversation_4 =
9699
evtSubConv = Nothing,
97100
evtFrom = Qualified {qUnqualified = Id (fromJust (UUID.fromString "2126ea99-ca79-43ea-ad99-a59616468e8e")), qDomain = Domain {_domainText = "97k-u0.b-5c"}},
98101
evtTime = UTCTime {utctDay = ModifiedJulianDay 58119, utctDayTime = 0},
99-
evtData = EdConvAccessUpdate (ConversationAccessData {cupAccess = fromList [PrivateAccess, CodeAccess], cupAccessRoles = fromList []})
102+
evtData = EdConvAccessUpdate (ConversationAccessData {cupAccess = fromList [PrivateAccess, CodeAccess], cupAccessRoles = fromList []}),
103+
evtTeam = Nothing
100104
}
101105

102106
testObject_Event_conversation_5 :: Event
@@ -106,7 +110,8 @@ testObject_Event_conversation_5 =
106110
evtSubConv = Nothing,
107111
evtFrom = Qualified {qUnqualified = Id (fromJust (UUID.fromString "2126ea99-ca79-43ea-ad99-a59616468e8e")), qDomain = Domain {_domainText = "7.m4f7p.ez4zs61"}},
108112
evtTime = UTCTime {utctDay = ModifiedJulianDay 58119, utctDayTime = 0},
109-
evtData = EdMLSWelcome ""
113+
evtData = EdMLSWelcome "",
114+
evtTeam = Nothing
110115
}
111116

112117
testObject_Event_conversation_6 :: Event
@@ -116,7 +121,8 @@ testObject_Event_conversation_6 =
116121
evtSubConv = Nothing,
117122
evtFrom = Qualified {qUnqualified = Id (fromJust (UUID.fromString "2126ea99-ca79-43ea-ad99-a59616468e8e")), qDomain = Domain {_domainText = "8.0-6.t7pxv"}},
118123
evtTime = UTCTime {utctDay = ModifiedJulianDay 58119, utctDayTime = 0},
119-
evtData = EdOtrMessage (OtrMessage {otrSender = ClientId 1, otrRecipient = ClientId 1, otrCiphertext = "", otrData = Just "I\68655"})
124+
evtData = EdOtrMessage (OtrMessage {otrSender = ClientId 1, otrRecipient = ClientId 1, otrCiphertext = "", otrData = Just "I\68655"}),
125+
evtTeam = Nothing
120126
}
121127

122128
testObject_Event_conversation_7 :: Event
@@ -126,7 +132,8 @@ testObject_Event_conversation_7 =
126132
evtSubConv = Nothing,
127133
evtFrom = Qualified {qUnqualified = Id (fromJust (UUID.fromString "2126ea99-ca79-43ea-ad99-a59616468e8e")), qDomain = Domain {_domainText = "64b3--h.u"}},
128134
evtTime = UTCTime {utctDay = ModifiedJulianDay 58119, utctDayTime = 0},
129-
evtData = EdOtrMessage (OtrMessage {otrSender = ClientId 3, otrRecipient = ClientId 3, otrCiphertext = "%\SI", otrData = Nothing})
135+
evtData = EdOtrMessage (OtrMessage {otrSender = ClientId 3, otrRecipient = ClientId 3, otrCiphertext = "%\SI", otrData = Nothing}),
136+
evtTeam = Nothing
130137
}
131138

132139
testObject_Event_conversation_8 :: Event
@@ -136,7 +143,8 @@ testObject_Event_conversation_8 =
136143
evtSubConv = Nothing,
137144
evtFrom = Qualified {qUnqualified = Id (fromJust (UUID.fromString "2126ea99-ca79-43ea-ad99-a59616468e8e")), qDomain = Domain {_domainText = "0--gy.705nsa8.j4m"}},
138145
evtTime = UTCTime {utctDay = ModifiedJulianDay 58119, utctDayTime = 0},
139-
evtData = EdTyping StartedTyping
146+
evtData = EdTyping StartedTyping,
147+
evtTeam = Nothing
140148
}
141149

142150
testObject_Event_conversation_9 :: Event
@@ -171,7 +179,8 @@ testObject_Event_conversation_9 =
171179
Qualified {qUnqualified = Id (fromJust (UUID.fromString "2126ea99-ca79-43ea-ad99-a59616468e8e")), qDomain = Domain {_domainText = "ns.v2p"}}
172180
]
173181
}
174-
)
182+
),
183+
evtTeam = Nothing
175184
}
176185

177186
testObject_Event_conversation_10 :: Event
@@ -181,7 +190,8 @@ testObject_Event_conversation_10 =
181190
evtSubConv = Nothing,
182191
evtFrom = Qualified {qUnqualified = Id (fromJust (UUID.fromString "2126ea99-ca79-43ea-ad99-a59616468e8e")), qDomain = Domain {_domainText = "4-p.d7b8d3.6.c8--jds3-1acy"}},
183192
evtTime = UTCTime {utctDay = ModifiedJulianDay 58119, utctDayTime = 0},
184-
evtData = EdMLSMessage "s\b\138w\236\231P(\ESC\216\205"
193+
evtData = EdMLSMessage "s\b\138w\236\231P(\ESC\216\205",
194+
evtTeam = Nothing
185195
}
186196

187197
testObject_Event_conversation_11 :: Event
@@ -191,5 +201,6 @@ testObject_Event_conversation_11 =
191201
evtSubConv = Nothing,
192202
evtFrom = Qualified {qUnqualified = Id (fromJust (UUID.fromString "2126ea99-ca79-43ea-ad99-a59616468e8e")), qDomain = Domain {_domainText = "70-o.ncd"}},
193203
evtTime = UTCTime {utctDay = ModifiedJulianDay 58119, utctDayTime = 0},
194-
evtData = EdTyping StoppedTyping
204+
evtData = EdTyping StoppedTyping,
205+
evtTeam = Nothing
195206
}

libs/wire-api/test/golden/Test/Wire/API/Golden/Generated/Event_user.hs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ testObject_Event_user_1 =
4848
Nothing
4949
(Qualified (Id (fromJust (UUID.fromString "00003b8b-0000-3395-0000-076a00007830"))) (Domain "faraway.example.com"))
5050
(read "1864-05-22 09:51:07.104 UTC")
51+
(Just (Id (fromJust (UUID.fromString "90eda181-bb05-4525-a5cc-d0038deda9b7"))))
5152
EdConvDelete
5253

5354
testObject_Event_user_2 :: Event
@@ -57,6 +58,7 @@ testObject_Event_user_2 =
5758
Nothing
5859
(Qualified (Id (fromJust (UUID.fromString "00006a88-0000-2acb-0000-6aa0000061b2"))) (Domain "faraway.example.com"))
5960
(read "1864-06-05 23:01:18.769 UTC")
61+
Nothing
6062
( EdConvAccessUpdate
6163
( ConversationAccessData
6264
{ cupAccess = [InviteAccess, LinkAccess, PrivateAccess, InviteAccess, InviteAccess],
@@ -72,6 +74,7 @@ testObject_Event_user_3 =
7274
Nothing
7375
(Qualified (Id (fromJust (UUID.fromString "00004b11-0000-5504-0000-55d800002188"))) (Domain "faraway.example.com"))
7476
(read "1864-04-27 15:44:23.844 UTC")
77+
Nothing
7578
( EdOtrMessage
7679
( OtrMessage
7780
{ otrSender = ClientId 0xc,
@@ -89,6 +92,7 @@ testObject_Event_user_4 =
8992
Nothing
9093
(Qualified (Id (fromJust (UUID.fromString "00007c90-0000-766a-0000-01b700002ab7"))) (Domain "faraway.example.com"))
9194
(read "1864-05-12 00:59:09.2 UTC")
95+
Nothing
9296
EdConvCodeDelete
9397

9498
testObject_Event_user_5 :: Event
@@ -98,6 +102,7 @@ testObject_Event_user_5 =
98102
Nothing
99103
(Qualified (Id (fromJust (UUID.fromString "00002a12-0000-73e1-0000-71f700002ec9"))) (Domain "faraway.example.com"))
100104
(read "1864-04-12 03:04:00.298 UTC")
105+
Nothing
101106
( EdMemberUpdate
102107
( MemberUpdateData
103108
{ misTarget =
@@ -126,6 +131,7 @@ testObject_Event_user_6 =
126131
Nothing
127132
(Qualified (Id (fromJust (UUID.fromString "0000705a-0000-0b62-0000-425c000049c8"))) (Domain "faraway.example.com"))
128133
(read "1864-05-09 05:44:41.382 UTC")
134+
Nothing
129135
(EdConvMessageTimerUpdate (ConversationMessageTimerUpdate {cupMessageTimer = Just (Ms {ms = 5029817038083912})}))
130136

131137
testObject_Event_user_7 :: Event
@@ -135,6 +141,7 @@ testObject_Event_user_7 =
135141
Nothing
136142
(Qualified (Id (fromJust (UUID.fromString "0000355a-0000-2979-0000-083000002d5e"))) (Domain "faraway.example.com"))
137143
(read "1864-04-18 05:01:13.761 UTC")
144+
Nothing
138145
(EdTyping StoppedTyping)
139146

140147
testObject_Event_user_8 :: Event
@@ -144,6 +151,7 @@ testObject_Event_user_8 =
144151
Nothing
145152
(Qualified (Id (fromJust (UUID.fromString "00000457-0000-0689-0000-77a00000021c"))) (Domain "faraway.example.com"))
146153
(read "1864-05-29 19:31:31.226 UTC")
154+
Nothing
147155
( EdConversation
148156
( ConversationV8
149157
{ cnvQualifiedId = Qualified (Id (fromJust (UUID.fromString "00000000-0000-0000-0000-000100000001"))) (Domain "golden.example.com"),
@@ -211,6 +219,7 @@ testObject_Event_user_9 =
211219
Nothing
212220
(Qualified (Id (fromJust (UUID.fromString "00004bee-0000-45a0-0000-2c0300005726"))) (Domain "faraway.example.com"))
213221
(read "1864-05-01 11:57:35.123 UTC")
222+
Nothing
214223
(EdConvReceiptModeUpdate (ConversationReceiptModeUpdate {cruReceiptMode = ReceiptMode {unReceiptMode = -10505}}))
215224

216225
testObject_Event_user_10 :: Event
@@ -220,6 +229,7 @@ testObject_Event_user_10 =
220229
Nothing
221230
(Qualified (Id (fromJust (UUID.fromString "00007f28-0000-40b1-0000-56ab0000748d"))) (Domain "faraway.example.com"))
222231
(read "1864-05-25 01:31:49.802 UTC")
232+
Nothing
223233
( EdConnect
224234
( Connect
225235
{ cRecipient =
@@ -240,6 +250,7 @@ testObject_Event_user_11 =
240250
Nothing
241251
(Qualified (Id (fromJust (UUID.fromString "000043a6-0000-1627-0000-490300002017"))) (Domain "faraway.example.com"))
242252
(read "1864-04-12 01:28:25.705 UTC")
253+
Nothing
243254
( EdMembersLeave
244255
EdReasonLeft
245256
( QualifiedUserIdList
@@ -258,6 +269,7 @@ testObject_Event_user_12 =
258269
Nothing
259270
(Qualified (Id (fromJust (UUID.fromString "0000114a-0000-7da8-0000-40cb00007fcf"))) (Domain "faraway.example.com"))
260271
(read "1864-05-12 20:29:47.483 UTC")
272+
Nothing
261273
( EdMembersJoin
262274
( MembersJoin
263275
{ mMembers =
@@ -282,6 +294,7 @@ testObject_Event_user_13 =
282294
Nothing
283295
(Qualified (Id (fromJust (UUID.fromString "0000114a-0000-7da8-0000-40cb00007fcf"))) (Domain "faraway.example.com"))
284296
(read "1864-05-12 20:29:47.483 UTC")
297+
Nothing
285298
(EdConvRename (ConversationRename "New conversation name"))
286299

287300
testObject_Event_user_14 :: Event
@@ -291,6 +304,7 @@ testObject_Event_user_14 =
291304
Nothing
292305
(Qualified (Id (fromJust (UUID.fromString "0000114a-0000-7da8-0000-40cb00007fcf"))) (Domain "faraway.example.com"))
293306
(read "1864-05-12 20:29:47.483 UTC")
307+
Nothing
294308
(EdConvCodeUpdate cc)
295309
where
296310
cc =
@@ -310,6 +324,7 @@ testObject_Event_user_15 =
310324
Nothing
311325
(Qualified (Id (fromJust (UUID.fromString "04e68c50-027e-4e84-a33a-e2e28a7b8ea3"))) (Domain "faraway.example.com"))
312326
(read "2021-11-10 05:39:44.297 UTC")
327+
Nothing
313328
(EdMLSMessage "hello world")
314329

315330
testObject_Event_user_16 :: Event
@@ -319,4 +334,5 @@ testObject_Event_user_16 =
319334
Nothing
320335
(Qualified (Id (fromJust (UUID.fromString "e8f48b8f-fad3-4f60-98e3-a6df082c328d"))) (Domain "faraway.example.com"))
321336
(read "2021-05-12 13:12:01.005 UTC")
337+
Nothing
322338
(EdMLSWelcome "welcome message content")

libs/wire-api/test/golden/Test/Wire/API/Golden/Generated/RemoveBotResponse_user.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ testObject_RemoveBotResponse_user_1 =
3838
Nothing
3939
(Qualified (Id (fromJust (UUID.fromString "00004166-0000-1e32-0000-52cb0000428d"))) (Domain "faraway.example.com"))
4040
(read "1864-05-07 01:13:35.741 UTC")
41+
Nothing
4142
( EdMembersLeave
4243
EdReasonRemoved
4344
( QualifiedUserIdList

libs/wire-api/test/golden/Test/Wire/API/Golden/Manual/ConversationEvent.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ testObject_Event_conversation_manual_1 =
3434
evtSubConv = Just (SubConvId "call"),
3535
evtFrom = Qualified {qUnqualified = Id (fromJust (UUID.fromString "2126ea99-ca79-43ea-ad99-a59616468e8e")), qDomain = Domain {_domainText = "n8nl6tp.h5"}},
3636
evtTime = UTCTime {utctDay = ModifiedJulianDay 58119, utctDayTime = 0},
37-
evtData = EdConvCodeDelete
37+
evtData = EdConvCodeDelete,
38+
evtTeam = Nothing
3839
}
3940

4041
testObject_Event_conversation_manual_2 :: Event
@@ -44,5 +45,6 @@ testObject_Event_conversation_manual_2 =
4445
evtSubConv = Nothing,
4546
evtFrom = Qualified {qUnqualified = Id (fromJust (UUID.fromString "a471447c-aa30-4592-81b0-dec6c1c02bca")), qDomain = Domain {_domainText = "example.com"}},
4647
evtTime = UTCTime {utctDay = ModifiedJulianDay 58119, utctDayTime = 0},
47-
evtData = EdProtocolUpdate P.ProtocolMixedTag
48+
evtData = EdProtocolUpdate P.ProtocolMixedTag,
49+
evtTeam = Nothing
4850
}

0 commit comments

Comments
 (0)