Skip to content

Commit

Permalink
Limit the consume events endpoint to v8
Browse files Browse the repository at this point in the history
  • Loading branch information
mdimjasevic committed Dec 11, 2024
1 parent 67dab2f commit c551859
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 7 additions & 1 deletion integration/test/Test/Events.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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_
Expand Down
3 changes: 2 additions & 1 deletion libs/wire-api/src/Wire/API/Routes/Public/Cannon.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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'
Expand Down

0 comments on commit c551859

Please sign in to comment.