Skip to content

Commit

Permalink
move ClientCapability ClientSupportsConsumableNotifications to APIv8
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanwire committed Dec 6, 2024
1 parent 085f3f0 commit cd43dcd
Show file tree
Hide file tree
Showing 11 changed files with 182 additions and 141 deletions.
8 changes: 4 additions & 4 deletions integration/test/Test/Client.hs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ testUpdateClientWithConsumableNotificationsCapability = do
resp.status `shouldMatchInt` 200
resp.json %. "0.capabilities" `shouldMatch` [consumeCapability]

testGetClientCapabilitiesV6 :: App ()
testGetClientCapabilitiesV6 = do
testGetClientCapabilitiesV7 :: App ()
testGetClientCapabilitiesV7 = do
let allCapabilities = ["legalhold-implicit-consent", "consumable-notifications"]
alice <- randomUser OwnDomain def
addClient alice def {acapabilities = Just allCapabilities} `bindResponse` \resp -> do
Expand All @@ -116,8 +116,8 @@ testGetClientCapabilitiesV6 = do
resp.status `shouldMatchInt` 200
resp.json %. "0.capabilities" `shouldMatchSet` allCapabilities

-- In API v6 and below, the "capabilities" field is an enum, so having a new
-- In API v7 and below, the "capabilities" field is an enum, so having a new
-- value for this enum is a breaking change.
withAPIVersion 6 $ getSelfClients alice `bindResponse` \resp -> do
withAPIVersion 7 $ getSelfClients alice `bindResponse` \resp -> do
resp.status `shouldMatchInt` 200
resp.json %. "0.capabilities.capabilities" `shouldMatchSet` ["legalhold-implicit-consent"]
52 changes: 38 additions & 14 deletions libs/wire-api/src/Wire/API/Routes/Public/Brig.hs
Original file line number Diff line number Diff line change
Expand Up @@ -750,9 +750,9 @@ type UserClientAPI =
-- - ClientAdded event to self
-- - ClientRemoved event to self, if removing old clients due to max number
Named
"add-client-v6"
"add-client@v7"
( Summary "Register a new client"
:> Until 'V7
:> Until 'V8
:> CanThrow 'TooManyClients
:> CanThrow 'MissingAuth
:> CanThrow 'MalformedPrekeys
Expand All @@ -761,20 +761,20 @@ type UserClientAPI =
:> ZLocalUser
:> ZConn
:> "clients"
:> ReqBody '[JSON] NewClient
:> VersionedReqBody 'V7 '[JSON] NewClient
:> MultiVerb1
'POST
'[JSON]
( WithHeaders
ClientHeaders
Client
(VersionedRespond 'V6 201 "Client registered" Client)
(VersionedRespond 'V7 201 "Client registered" Client)
)
)
:<|> Named
"add-client"
( Summary "Register a new client"
:> From 'V7
:> From 'V8
:> CanThrow 'TooManyClients
:> CanThrow 'MissingAuth
:> CanThrow 'MalformedPrekeys
Expand All @@ -793,6 +793,17 @@ type UserClientAPI =
(Respond 201 "Client registered" Client)
)
)
:<|> Named
"update-client@v7"
( Summary "Update a registered client"
:> Until 'V8
:> CanThrow 'MalformedPrekeys
:> ZUser
:> "clients"
:> CaptureClientId "client"
:> VersionedReqBody 'V7 '[JSON] UpdateClient
:> MultiVerb1 'PUT '[JSON] (RespondEmpty 200 "Client updated")
)
:<|> Named
"update-client"
( Summary "Update a registered client"
Expand All @@ -801,7 +812,7 @@ type UserClientAPI =
:> "clients"
:> CaptureClientId "client"
:> ReqBody '[JSON] UpdateClient
:> MultiVerb 'PUT '[JSON] '[RespondEmpty 200 "Client updated"] ()
:> MultiVerb1 'PUT '[JSON] (RespondEmpty 200 "Client updated")
)
:<|>
-- This endpoint can lead to the following events being sent:
Expand All @@ -817,21 +828,21 @@ type UserClientAPI =
:> MultiVerb 'DELETE '[JSON] '[RespondEmpty 200 "Client deleted"] ()
)
:<|> Named
"list-clients-v6"
"list-clients@v7"
( Summary "List the registered clients"
:> Until 'V7
:> Until 'V8
:> ZUser
:> "clients"
:> MultiVerb1
'GET
'[JSON]
( VersionedRespond 'V6 200 "List of clients" [Client]
( VersionedRespond 'V7 200 "List of clients" [Client]
)
)
:<|> Named
"list-clients"
( Summary "List the registered clients"
:> From 'V7
:> From 'V8
:> ZUser
:> "clients"
:> MultiVerb1
Expand All @@ -841,24 +852,24 @@ type UserClientAPI =
)
)
:<|> Named
"get-client-v6"
"get-client@v7"
( Summary "Get a registered client by ID"
:> Until 'V7
:> Until 'V8
:> ZUser
:> "clients"
:> CaptureClientId "client"
:> MultiVerb
'GET
'[JSON]
'[ EmptyErrorForLegacyReasons 404 "Client not found",
VersionedRespond 'V6 200 "Client found" Client
VersionedRespond 'V7 200 "Client found" Client
]
(Maybe Client)
)
:<|> Named
"get-client"
( Summary "Get a registered client by ID"
:> From 'V7
:> From 'V8
:> ZUser
:> "clients"
:> CaptureClientId "client"
Expand All @@ -870,6 +881,19 @@ type UserClientAPI =
]
(Maybe Client)
)
:<|> Named
"get-client-capabilities@v7"
( Summary "Read back what the client has been posting about itself"
:> Until 'V8
:> ZUser
:> "clients"
:> CaptureClientId "client"
:> "capabilities"
:> MultiVerb1
'GET
'[JSON]
(VersionedRespond 'V7 200 "capabilities" ClientCapabilityList)
)
:<|> Named
"get-client-capabilities"
( Summary "Read back what the client has been posting about itself"
Expand Down
8 changes: 4 additions & 4 deletions libs/wire-api/src/Wire/API/Routes/Public/Brig/Bot.hs
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ type BotAPI =
:> MultiVerb1 'POST '[JSON] (RespondEmpty 200 "")
)
:<|> Named
"bot-get-client-v6"
"bot-get-client@v7"
( Summary "Get client for bot"
:> Until 'V7
:> Until 'V8
:> CanThrow 'AccessDenied
:> CanThrow 'ClientNotFound
:> ZBot
Expand All @@ -158,14 +158,14 @@ type BotAPI =
'GET
'[JSON]
'[ ErrorResponse 'ClientNotFound,
VersionedRespond 'V6 200 "Client found" Client
VersionedRespond 'V7 200 "Client found" Client
]
(Maybe Client)
)
:<|> Named
"bot-get-client"
( Summary "Get client for bot"
:> From 'V7
:> From 'V8
:> CanThrow 'AccessDenied
:> CanThrow 'ClientNotFound
:> ZBot
Expand Down
3 changes: 3 additions & 0 deletions libs/wire-api/src/Wire/API/Routes/Public/Cannon.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type CannonAPI =
Named
"await-notifications"
( Summary "Establish websocket connection"
-- Description "This is the legacy variant of \"consume-events\""
:> "await"
:> ZUser
:> ZConn
Expand All @@ -44,6 +45,8 @@ type CannonAPI =
:<|> Named
"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
:> "events"
:> ZUser
:> QueryParam'
Expand Down
Loading

0 comments on commit cd43dcd

Please sign in to comment.