Skip to content

Commit

Permalink
fixup! fixup! move ClientCapability ClientSupportsConsumableNotificat…
Browse files Browse the repository at this point in the history
…ions to APIv8
  • Loading branch information
stefanwire committed Dec 4, 2024
1 parent b18399e commit aea355b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 3 additions & 3 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 @@ -118,6 +118,6 @@ testGetClientCapabilitiesV6 = do

-- In API v6 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"]
10 changes: 9 additions & 1 deletion libs/wire-api/src/Wire/API/User/Client.hs
Original file line number Diff line number Diff line change
Expand Up @@ -520,9 +520,17 @@ clientSchema mVersion =
<*> clientLabel .= maybe_ (optField "label" schema)
<*> clientCookie .= maybe_ (optField "cookie" schema)
<*> clientModel .= maybe_ (optField "model" schema)
<*> clientCapabilities .= (fromMaybe mempty <$> optField "capabilities" (capabilitiesSchema mVersion))
<*> clientCapabilities .= (fromMaybe mempty <$> optField "capabilities" caps)
<*> clientMLSPublicKeys .= mlsPublicKeysFieldSchema
<*> clientLastActive .= maybe_ (optField "last_active" utcTimeSchema)
where
caps :: ValueSchema NamedSwaggerDoc ClientCapabilityList
caps = case mVersion of
-- broken capability serialisation for backwards compatibility
Just v
| v <= V7 ->
dimap Versioned unVersioned $ schema @(Versioned V7 ClientCapabilityList)
_ -> schema @ClientCapabilityList

instance ToSchema Client where
schema = clientSchema Nothing
Expand Down

0 comments on commit aea355b

Please sign in to comment.