From c551859c3ac9cc0192b554922dc34b11acef2111 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Dimja=C5=A1evi=C4=87?= Date: Tue, 10 Dec 2024 16:49:42 +0100 Subject: [PATCH] Limit the consume events endpoint to v8 --- integration/test/Test/Events.hs | 8 +++++++- libs/wire-api/src/Wire/API/Routes/Public/Cannon.hs | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/integration/test/Test/Events.hs b/integration/test/Test/Events.hs index 2400b1c9f2c..795ba3b7779 100644 --- a/integration/test/Test/Events.hs +++ b/integration/test/Test/Events.hs @@ -346,9 +346,15 @@ createEventsWebSocket user cid = do eventsChan <- liftIO newChan ackChan <- liftIO newEmptyMVar serviceMap <- lift $ getServiceMap =<< objDomain user + apiVersion <- lift $ getAPIVersionFor $ objDomain user + let minAPIVersion = 8 + lift + . when (apiVersion < minAPIVersion) + $ assertFailure ("Events websocket can only be created when APIVersion is at least " <> show minAPIVersion) + uid <- lift $ objId =<< objQidObject user let HostPort caHost caPort = serviceHostPort serviceMap Cannon - path = "/events?client=" <> cid + path = "/v" <> show apiVersion <> "/events?client=" <> cid caHdrs = [(fromString "Z-User", toByteString' uid)] app conn = race_ diff --git a/libs/wire-api/src/Wire/API/Routes/Public/Cannon.hs b/libs/wire-api/src/Wire/API/Routes/Public/Cannon.hs index 03742511080..b339371be08 100644 --- a/libs/wire-api/src/Wire/API/Routes/Public/Cannon.hs +++ b/libs/wire-api/src/Wire/API/Routes/Public/Cannon.hs @@ -22,6 +22,7 @@ import Servant import Wire.API.Routes.API import Wire.API.Routes.Named import Wire.API.Routes.Public (ZConn, ZUser) +import Wire.API.Routes.Version import Wire.API.Routes.WebSocket type CannonAPI = @@ -46,7 +47,7 @@ type CannonAPI = "consume-events" ( Summary "Consume events over a websocket connection" :> Description "This is the rabbitMQ-based variant of \"await-notifications\"" - -- :> From 'V8 -- cannon is not versioned yet + :> From 'V8 :> "events" :> ZUser :> QueryParam'