Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
pcapriotti committed Dec 4, 2024
1 parent 7917bc6 commit 27df25b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
3 changes: 1 addition & 2 deletions libs/wire-api/src/Wire/API/Routes/Public/Cannon.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ type CannonAPI =
:> "events"
:> ZUser
:> QueryParam'
[ -- Make this optional in https://wearezeta.atlassian.net/browse/WPB-11173
Required,
[ Optional,
Strict,
Description "Client ID"
]
Expand Down
6 changes: 3 additions & 3 deletions services/cannon/src/Cannon/API/Public.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ streamData userId connId clientId con = do
e <- wsenv
liftIO $ wsapp (mkKey userId connId) clientId e con

consumeEvents :: UserId -> ClientId -> PendingConnection -> Cannon ()
consumeEvents userId clientId con = do
consumeEvents :: UserId -> Maybe ClientId -> PendingConnection -> Cannon ()
consumeEvents userId mClientId con = do
e <- wsenv
liftIO $ rabbitMQWebSocketApp userId clientId e con
liftIO $ rabbitMQWebSocketApp userId mClientId e con
12 changes: 6 additions & 6 deletions services/cannon/src/Cannon/RabbitMqConsumerApp.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import System.Logger qualified as Log
import Wire.API.Event.WebSocketProtocol
import Wire.API.Notification

rabbitMQWebSocketApp :: UserId -> ClientId -> Env -> ServerApp
rabbitMQWebSocketApp uid cid e pendingConn = do
rabbitMQWebSocketApp :: UserId -> Maybe ClientId -> Env -> ServerApp
rabbitMQWebSocketApp uid mcid e pendingConn = do
bracket openWebSocket closeWebSocket $ \wsConn ->
( do
sendFullSyncMessageIfNeeded wsConn uid cid e
traverse_ (sendFullSyncMessageIfNeeded wsConn uid e) mcid
sendNotifications wsConn
)
`catches` [ handleClientMisbehaving wsConn,
Expand All @@ -34,7 +34,7 @@ rabbitMQWebSocketApp uid cid e pendingConn = do
where
logClient =
Log.field "user" (idToText uid)
. Log.field "client" (clientToText cid)
. Log.field "client" (maybe "<temporary>" clientToText mcid)

openWebSocket =
acceptRequest pendingConn
Expand Down Expand Up @@ -171,10 +171,10 @@ rabbitMQWebSocketApp uid cid e pendingConn = do
sendFullSyncMessageIfNeeded ::
WS.Connection ->
UserId ->
ClientId ->
Env ->
ClientId ->
IO ()
sendFullSyncMessageIfNeeded wsConn uid cid env = do
sendFullSyncMessageIfNeeded wsConn uid env cid = do
row <- C.runClient env.cassandra do
retry x5 $ query1 q (params LocalQuorum (uid, cid))
for_ row $ \_ -> sendFullSyncMessage uid cid wsConn env
Expand Down

0 comments on commit 27df25b

Please sign in to comment.