From aea355bb81f9b7a116f9bdb857e223df32ffae12 Mon Sep 17 00:00:00 2001 From: Stefan Berthold Date: Wed, 4 Dec 2024 15:18:04 +0000 Subject: [PATCH] fixup! fixup! move ClientCapability ClientSupportsConsumableNotifications to APIv8 --- integration/test/Test/Client.hs | 6 +++--- libs/wire-api/src/Wire/API/User/Client.hs | 10 +++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/integration/test/Test/Client.hs b/integration/test/Test/Client.hs index 8c3101737dd..10c11db6c78 100644 --- a/integration/test/Test/Client.hs +++ b/integration/test/Test/Client.hs @@ -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 @@ -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"] diff --git a/libs/wire-api/src/Wire/API/User/Client.hs b/libs/wire-api/src/Wire/API/User/Client.hs index acff0c7ea71..79aa53595c2 100644 --- a/libs/wire-api/src/Wire/API/User/Client.hs +++ b/libs/wire-api/src/Wire/API/User/Client.hs @@ -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