Skip to content

Commit 347f5a7

Browse files
committed
Use EmptyResponse consistently for galley fed calls
1 parent ab79f33 commit 347f5a7

File tree

4 files changed

+33
-31
lines changed

4 files changed

+33
-31
lines changed

libs/wire-api-federation/src/Wire/API/Federation/API/Galley.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ type GalleyApi =
5454
-- that are part of a conversation at creation time. Since MLS conversations
5555
-- are always created empty (i.e. they only contain the creator), this RPC is
5656
-- never invoked for such conversations.
57-
FedEndpoint "on-conversation-created" (ConversationCreated ConvId) ()
57+
FedEndpoint "on-conversation-created" (ConversationCreated ConvId) EmptyResponse
5858
-- This endpoint is called the first time a user from this backend is
5959
-- added to a remote conversation.
6060
:<|> FedEndpoint "on-new-remote-conversation" NewRemoteConversation EmptyResponse
6161
:<|> FedEndpoint "get-conversations" GetConversationsRequest GetConversationsResponse
6262
-- used by the backend that owns a conversation to inform this backend of
6363
-- changes to the conversation
64-
:<|> FedEndpoint "on-conversation-updated" ConversationUpdate ()
64+
:<|> FedEndpoint "on-conversation-updated" ConversationUpdate EmptyResponse
6565
:<|> FedEndpointWithMods
6666
'[ MakesFederatedCall 'Galley "on-conversation-updated",
6767
MakesFederatedCall 'Galley "on-mls-message-sent",
@@ -72,7 +72,7 @@ type GalleyApi =
7272
LeaveConversationResponse
7373
-- used to notify this backend that a new message has been posted to a
7474
-- remote conversation
75-
:<|> FedEndpoint "on-message-sent" (RemoteMessage ConvId) ()
75+
:<|> FedEndpoint "on-message-sent" (RemoteMessage ConvId) EmptyResponse
7676
-- used by a remote backend to send a message to a conversation owned by
7777
-- this backend
7878
:<|> FedEndpointWithMods

services/galley/src/Galley/API/Federation.hs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ onConversationCreated ::
156156
) =>
157157
Domain ->
158158
F.ConversationCreated ConvId ->
159-
Sem r ()
159+
Sem r EmptyResponse
160160
onConversationCreated domain rc = do
161161
let qrc = fmap (toRemoteUnsafe domain) rc
162162
loc <- qualifyLocal ()
@@ -189,6 +189,7 @@ onConversationCreated domain rc = do
189189
(F.ccTime qrcConnected)
190190
(EdConversation c)
191191
pushConversationEvent Nothing event (qualifyAs loc [qUnqualified . Public.memId $ mem]) []
192+
pure EmptyResponse
192193

193194
onNewRemoteConversation ::
194195
Member ConversationStore r =>
@@ -227,9 +228,10 @@ onConversationUpdated ::
227228
) =>
228229
Domain ->
229230
F.ConversationUpdate ->
230-
Sem r ()
231+
Sem r EmptyResponse
231232
onConversationUpdated requestingDomain cu =
232233
updateLocalStateOfRemoteConv requestingDomain cu
234+
>> pure EmptyResponse
233235

234236
-- as of now this will not generate the necessary events on the leaver's domain
235237
leaveConversation ::
@@ -314,7 +316,7 @@ onMessageSent ::
314316
) =>
315317
Domain ->
316318
F.RemoteMessage ConvId ->
317-
Sem r ()
319+
Sem r EmptyResponse
318320
onMessageSent domain rmUnqualified = do
319321
let rm = fmap (toRemoteUnsafe domain) rmUnqualified
320322
convId = tUntagged $ F.rmConversation rm
@@ -351,6 +353,7 @@ onMessageSent domain rmUnqualified = do
351353
mempty
352354
msgMetadata
353355
(Map.filterWithKey (\(uid, _) _ -> Set.member uid members) msgs)
356+
pure EmptyResponse
354357

355358
sendMessage ::
356359
( Member BrigAccess r,

services/galley/test/integration/API.hs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2192,7 +2192,7 @@ paginateConvListIds = do
21922192
F.cuAlreadyPresentUsers = [],
21932193
F.cuAction = SomeConversationAction (sing @'ConversationJoinTag) (ConversationJoin (pure qAlice) roleNameWireMember)
21942194
}
2195-
runFedClient @"on-conversation-updated" fedGalleyClient chadDomain cu
2195+
void $ runFedClient @"on-conversation-updated" fedGalleyClient chadDomain cu
21962196

21972197
remoteDee <- randomId
21982198
let deeDomain = Domain "dee.example.com"
@@ -2208,7 +2208,7 @@ paginateConvListIds = do
22082208
F.cuAlreadyPresentUsers = [],
22092209
F.cuAction = SomeConversationAction (sing @'ConversationJoinTag) (ConversationJoin (pure qAlice) roleNameWireMember)
22102210
}
2211-
runFedClient @"on-conversation-updated" fedGalleyClient deeDomain cu
2211+
void $ runFedClient @"on-conversation-updated" fedGalleyClient deeDomain cu
22122212

22132213
-- 1 Proteus self conv + 1 MLS self conv + 2 convs with bob and eve + 196
22142214
-- local convs + 25 convs on chad.example.com + 31 on dee.example = 256 convs.
@@ -2253,7 +2253,7 @@ paginateConvListIdsPageEndingAtLocalsAndDomain = do
22532253
F.cuAlreadyPresentUsers = [],
22542254
F.cuAction = SomeConversationAction (sing @'ConversationJoinTag) (ConversationJoin (pure qAlice) roleNameWireMember)
22552255
}
2256-
runFedClient @"on-conversation-updated" fedGalleyClient chadDomain cu
2256+
void $ runFedClient @"on-conversation-updated" fedGalleyClient chadDomain cu
22572257

22582258
remoteDee <- randomId
22592259
let deeDomain = Domain "dee.example.com"
@@ -2271,7 +2271,7 @@ paginateConvListIdsPageEndingAtLocalsAndDomain = do
22712271
F.cuAlreadyPresentUsers = [],
22722272
F.cuAction = SomeConversationAction (sing @'ConversationJoinTag) (ConversationJoin (pure qAlice) roleNameWireMember)
22732273
}
2274-
runFedClient @"on-conversation-updated" fedGalleyClient deeDomain cu
2274+
void $ runFedClient @"on-conversation-updated" fedGalleyClient deeDomain cu
22752275

22762276
foldM_ (getChunkedConvs 16 0 alice) Nothing [4, 3, 2, 1, 0 :: Int]
22772277

@@ -3922,7 +3922,7 @@ putRemoteConvMemberOk update = do
39223922
cuAction =
39233923
SomeConversationAction (sing @'ConversationJoinTag) (ConversationJoin (pure qalice) roleNameWireMember)
39243924
}
3925-
runFedClient @"on-conversation-updated" fedGalleyClient remoteDomain cu
3925+
void $ runFedClient @"on-conversation-updated" fedGalleyClient remoteDomain cu
39263926

39273927
-- Expected member state
39283928
let memberAlice =
@@ -4067,7 +4067,7 @@ putRemoteReceiptModeOk = do
40674067
cuAction =
40684068
SomeConversationAction (sing @'ConversationJoinTag) (ConversationJoin (pure qalice) roleNameWireAdmin)
40694069
}
4070-
runFedClient @"on-conversation-updated" fedGalleyClient remoteDomain cuAddAlice
4070+
void $ runFedClient @"on-conversation-updated" fedGalleyClient remoteDomain cuAddAlice
40714071

40724072
-- add another user adam as member
40734073
qadam <- randomQualifiedUser
@@ -4082,7 +4082,7 @@ putRemoteReceiptModeOk = do
40824082
cuAction =
40834083
SomeConversationAction (sing @'ConversationJoinTag) (ConversationJoin (pure qadam) roleNameWireMember)
40844084
}
4085-
runFedClient @"on-conversation-updated" fedGalleyClient remoteDomain cuAddAdam
4085+
void $ runFedClient @"on-conversation-updated" fedGalleyClient remoteDomain cuAddAdam
40864086

40874087
let newReceiptMode = ReceiptMode 42
40884088
let action = ConversationReceiptModeUpdate newReceiptMode
@@ -4398,10 +4398,10 @@ removeUser = do
43984398
F.ccReceiptMode = Nothing,
43994399
F.ccProtocol = ProtocolProteus
44004400
}
4401-
runFedClient @"on-conversation-created" fedGalleyClient bDomain $ nc convB1 bart [alice, alexDel]
4402-
runFedClient @"on-conversation-created" fedGalleyClient bDomain $ nc convB2 bart [alexDel]
4403-
runFedClient @"on-conversation-created" fedGalleyClient cDomain $ nc convC1 carl [alexDel]
4404-
runFedClient @"on-conversation-created" fedGalleyClient dDomain $ nc convD1 dory [alexDel]
4401+
void $ runFedClient @"on-conversation-created" fedGalleyClient bDomain $ nc convB1 bart [alice, alexDel]
4402+
void $ runFedClient @"on-conversation-created" fedGalleyClient bDomain $ nc convB2 bart [alexDel]
4403+
void $ runFedClient @"on-conversation-created" fedGalleyClient cDomain $ nc convC1 carl [alexDel]
4404+
void $ runFedClient @"on-conversation-created" fedGalleyClient dDomain $ nc convD1 dory [alexDel]
44054405

44064406
WS.bracketR3 c alice' alexDel' amy' $ \(wsAlice, wsAlexDel, wsAmy) -> do
44074407
let handler = do

services/galley/test/integration/API/Federation.hs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ addLocalUser = do
254254
SomeConversationAction (sing @'ConversationJoinTag) (ConversationJoin (qalice :| [qdee]) roleNameWireMember)
255255
}
256256
WS.bracketRN c [alice, charlie, dee] $ \[wsA, wsC, wsD] -> do
257-
runFedClient @"on-conversation-updated" fedGalleyClient remoteDomain cu
257+
void $ runFedClient @"on-conversation-updated" fedGalleyClient remoteDomain cu
258258
liftIO $ do
259259
WS.assertMatch_ (5 # Second) wsA $
260260
wsAssertMemberJoinWithRole qconv qbob [qalice] roleNameWireMember
@@ -308,7 +308,7 @@ addUnconnectedUsersOnly = do
308308
SomeConversationAction (sing @'ConversationJoinTag) (ConversationJoin (qCharlie :| []) roleNameWireMember)
309309
}
310310
-- Alice receives no notifications from this
311-
runFedClient @"on-conversation-updated" fedGalleyClient remoteDomain cu
311+
void $ runFedClient @"on-conversation-updated" fedGalleyClient remoteDomain cu
312312
WS.assertNoEvent (5 # Second) [wsA]
313313

314314
-- | This test invokes the federation endpoint:
@@ -353,9 +353,9 @@ removeLocalUser = do
353353

354354
connectWithRemoteUser alice qBob
355355
WS.bracketR c alice $ \ws -> do
356-
runFedClient @"on-conversation-updated" fedGalleyClient remoteDomain cuAdd
356+
void $ runFedClient @"on-conversation-updated" fedGalleyClient remoteDomain cuAdd
357357
afterAddition <- listRemoteConvs remoteDomain alice
358-
runFedClient @"on-conversation-updated" fedGalleyClient remoteDomain cuRemove
358+
void $ runFedClient @"on-conversation-updated" fedGalleyClient remoteDomain cuRemove
359359
liftIO $ do
360360
void . WS.assertMatch (3 # Second) ws $
361361
wsAssertMemberJoinWithRole qconv qBob [qAlice] roleNameWireMember
@@ -416,21 +416,21 @@ removeRemoteUser = do
416416
}
417417

418418
WS.bracketRN c [alice, charlie, dee, flo] $ \[wsA, wsC, wsD, wsF] -> do
419-
runFedClient @"on-conversation-updated" fedGalleyClient remoteDomain (cuRemove qEve)
419+
void $ runFedClient @"on-conversation-updated" fedGalleyClient remoteDomain (cuRemove qEve)
420420
liftIO $ do
421421
WS.assertMatchN_ (3 # Second) [wsA, wsD] $
422422
wsAssertMembersLeave qconv qBob [qEve]
423423
WS.assertNoEvent (1 # Second) [wsC, wsF]
424424

425425
WS.bracketRN c [alice, charlie, dee, flo] $ \[wsA, wsC, wsD, wsF] -> do
426-
runFedClient @"on-conversation-updated" fedGalleyClient remoteDomain (cuRemove qDee)
426+
void $ runFedClient @"on-conversation-updated" fedGalleyClient remoteDomain (cuRemove qDee)
427427
liftIO $ do
428428
WS.assertMatchN_ (3 # Second) [wsA, wsD] $
429429
wsAssertMembersLeave qconv qBob [qDee]
430430
WS.assertNoEvent (1 # Second) [wsC, wsF]
431431

432432
WS.bracketRN c [alice, charlie, dee, flo] $ \[wsA, wsC, wsD, wsF] -> do
433-
runFedClient @"on-conversation-updated" fedGalleyClient remoteDomain (cuRemove qFlo)
433+
void $ runFedClient @"on-conversation-updated" fedGalleyClient remoteDomain (cuRemove qFlo)
434434
liftIO $ do
435435
WS.assertMatchN_ (3 # Second) [wsA] $
436436
wsAssertMembersLeave qconv qBob [qFlo]
@@ -467,7 +467,7 @@ notifyUpdate extras action etype edata = do
467467
FedGalley.cuAction = action
468468
}
469469
WS.bracketR2 c alice charlie $ \(wsA, wsC) -> do
470-
runFedClient @"on-conversation-updated" fedGalleyClient bdom cu
470+
void $ runFedClient @"on-conversation-updated" fedGalleyClient bdom cu
471471
liftIO $ do
472472
WS.assertMatch_ (5 # Second) wsA $ \n -> do
473473
let e = List1.head (WS.unpackPayload n)
@@ -511,8 +511,7 @@ notifyUpdateUnavailable extras action etype edata = do
511511
WS.bracketR2 c alice charlie $ \(wsA, wsC) -> do
512512
((), _fedRequests) <-
513513
withTempMockFederator' (throw $ MockErrorResponse Http.status500 "Down for maintenance") $
514-
void $
515-
runFedClient @"on-conversation-updated" fedGalleyClient bdom cu
514+
void $ runFedClient @"on-conversation-updated" fedGalleyClient bdom cu
516515
liftIO $ do
517516
WS.assertMatch_ (5 # Second) wsA $ \n -> do
518517
let e = List1.head (WS.unpackPayload n)
@@ -644,7 +643,7 @@ notifyDeletedConversation = do
644643
FedGalley.cuAlreadyPresentUsers = [alice],
645644
FedGalley.cuAction = SomeConversationAction (sing @'ConversationDeleteTag) ()
646645
}
647-
runFedClient @"on-conversation-updated" fedGalleyClient bobDomain cu
646+
void $ runFedClient @"on-conversation-updated" fedGalleyClient bobDomain cu
648647

649648
liftIO $ do
650649
WS.assertMatch_ (5 # Second) wsAlice $ \n -> do
@@ -702,7 +701,7 @@ addRemoteUser = do
702701
SomeConversationAction (sing @'ConversationJoinTag) (ConversationJoin (qdee :| [qeve, qflo]) roleNameWireMember)
703702
}
704703
WS.bracketRN c (map qUnqualified [qalice, qcharlie, qdee, qflo]) $ \[wsA, wsC, wsD, wsF] -> do
705-
runFedClient @"on-conversation-updated" fedGalleyClient bdom cu
704+
void $ runFedClient @"on-conversation-updated" fedGalleyClient bdom cu
706705
void . liftIO $ do
707706
WS.assertMatchN_ (5 # Second) [wsA, wsD] $
708707
wsAssertMemberJoinWithRole qconv qbob [qeve, qdee] roleNameWireMember
@@ -847,7 +846,7 @@ onMessageSent = do
847846
FedGalley.cuAction =
848847
SomeConversationAction (sing @'ConversationJoinTag) (ConversationJoin (pure qalice) roleNameWireMember)
849848
}
850-
runFedClient @"on-conversation-updated" fedGalleyClient bdom cu
849+
void $ runFedClient @"on-conversation-updated" fedGalleyClient bdom cu
851850

852851
let txt = "Hello from another backend"
853852
msg client = Map.fromList [(client, txt)]
@@ -869,7 +868,7 @@ onMessageSent = do
869868

870869
-- send message to alice and check reception
871870
WS.bracketAsClientRN c [(alice, aliceC1), (alice, aliceC2), (eve, eveC)] $ \[wsA1, wsA2, wsE] -> do
872-
runFedClient @"on-message-sent" fedGalleyClient bdom rm
871+
void $ runFedClient @"on-message-sent" fedGalleyClient bdom rm
873872
liftIO $ do
874873
-- alice should receive the message on her first client
875874
WS.assertMatch_ (5 # Second) wsA1 $ \n -> do

0 commit comments

Comments
 (0)