From 753a7af235e53ea22ce583eeadf92d30982b3e9e Mon Sep 17 00:00:00 2001 From: Paolo Capriotti Date: Wed, 6 Oct 2021 17:05:11 +0200 Subject: [PATCH 1/3] Remove deprecated endpoint for listing convs Also removed the V2 from the name of the endpoint (in the code, not in the endpoint path). --- .../remove-list-conversations-endpoint | 1 + libs/wire-api/src/Wire/API/Conversation.hs | 27 +--- .../src/Wire/API/Routes/Public/Galley.hs | 19 +-- ...on => testObject_ListConversations_1.json} | 0 .../test/unit/Test/Wire/API/Golden/Manual.hs | 6 +- ...onversationsV2.hs => ListConversations.hs} | 10 +- libs/wire-api/wire-api.cabal | 4 +- services/galley/src/Galley/API/Public.hs | 1 - services/galley/src/Galley/API/Query.hs | 51 +------- services/galley/test/integration/API.hs | 120 +----------------- services/galley/test/integration/API/Util.hs | 29 ----- 11 files changed, 25 insertions(+), 243 deletions(-) create mode 100644 changelog.d/1-api-changes/remove-list-conversations-endpoint rename libs/wire-api/test/golden/{testObject_ListConversationsV2_1.json => testObject_ListConversations_1.json} (100%) rename libs/wire-api/test/unit/Test/Wire/API/Golden/Manual/{ListConversationsV2.hs => ListConversations.hs} (84%) diff --git a/changelog.d/1-api-changes/remove-list-conversations-endpoint b/changelog.d/1-api-changes/remove-list-conversations-endpoint new file mode 100644 index 00000000000..60539f03a99 --- /dev/null +++ b/changelog.d/1-api-changes/remove-list-conversations-endpoint @@ -0,0 +1 @@ +Remove `POST /list-conversations` endpoint. diff --git a/libs/wire-api/src/Wire/API/Conversation.hs b/libs/wire-api/src/Wire/API/Conversation.hs index ad7bdd5311e..e65b0e0a884 100644 --- a/libs/wire-api/src/Wire/API/Conversation.hs +++ b/libs/wire-api/src/Wire/API/Conversation.hs @@ -37,7 +37,6 @@ module Wire.API.Conversation ConversationCoverView (..), ConversationList (..), ListConversations (..), - ListConversationsV2 (..), GetPaginatedConversationIds, pattern GetPaginatedConversationIds, ConvIdsPage, @@ -359,37 +358,19 @@ type GetPaginatedConversationIds = GetMultiTablePageRequest ConversationPagingNa pattern GetPaginatedConversationIds :: Maybe (MultiTablePagingState name tables) -> Range 1 max Int32 -> GetMultiTablePageRequest name tables max def pattern GetPaginatedConversationIds state size = GetMultiTablePageRequest size state -data ListConversations = ListConversations - { lQualifiedIds :: Maybe (NonEmpty (Qualified ConvId)), - lStartId :: Maybe (Qualified ConvId), - lSize :: Maybe (Range 1 500 Int32) - } - deriving stock (Eq, Show, Generic) - deriving (FromJSON, ToJSON, S.ToSchema) via Schema ListConversations - -instance ToSchema ListConversations where - schema = - objectWithDocModifier - "ListConversations" - (description ?~ "A request to list some or all of a user's conversations, including remote ones") - $ ListConversations - <$> lQualifiedIds .= optField "qualified_ids" Nothing (nonEmptyArray schema) - <*> lStartId .= optField "start_id" Nothing schema - <*> lSize .= optField "size" Nothing schema - -- | Used on the POST /conversations/list/v2 endpoint -newtype ListConversationsV2 = ListConversationsV2 +newtype ListConversations = ListConversations { lcQualifiedIds :: Range 1 1000 [Qualified ConvId] } deriving stock (Eq, Show, Generic) - deriving (FromJSON, ToJSON, S.ToSchema) via Schema ListConversationsV2 + deriving (FromJSON, ToJSON, S.ToSchema) via Schema ListConversations -instance ToSchema ListConversationsV2 where +instance ToSchema ListConversations where schema = objectWithDocModifier "ListConversations" (description ?~ "A request to list some of a user's conversations, including remote ones. Maximum 1000 qualified conversation IDs") - $ ListConversationsV2 + $ ListConversations <$> (fromRange . lcQualifiedIds) .= field "qualified_ids" (rangedSchema sing sing (array schema)) data ConversationsResponse = ConversationsResponse diff --git a/libs/wire-api/src/Wire/API/Routes/Public/Galley.hs b/libs/wire-api/src/Wire/API/Routes/Public/Galley.hs index 7ba622cd808..41cd9d2ae17 100644 --- a/libs/wire-api/src/Wire/API/Routes/Public/Galley.hs +++ b/libs/wire-api/src/Wire/API/Routes/Public/Galley.hs @@ -141,7 +141,10 @@ data Api routes = Api getConversations :: routes :- Summary "Get all *local* conversations." - :> Description "Will not return remote conversations (will eventually be deprecated in favour of list-conversations)" + :> Description + "Will not return remote conversations.\n\n\ + \Use `POST /conversations/list-ids` followed by \ + \`POST /conversations/list/v2` instead." :> ZUser :> "conversations" :> QueryParam' @@ -167,25 +170,13 @@ data Api routes = Api (Range 1 500 Int32) :> Get '[Servant.JSON] (ConversationList Conversation), listConversations :: - routes - :- Summary "[deprecated] Get all conversations (also returns remote conversations)" - :> Description - "Like GET /conversations, but allows specifying a list of remote conversations in its request body. \ - \Will return all or the requested qualified conversations, including remote ones. \ - \Size parameter is not yet honoured for remote conversations.\n\ - \**NOTE** This endpoint will soon be removed." - :> ZUser - :> "list-conversations" - :> ReqBody '[Servant.JSON] ListConversations - :> Post '[Servant.JSON] (ConversationList Conversation), - listConversationsV2 :: routes :- Summary "Get conversation metadata for a list of conversation ids" :> ZUser :> "conversations" :> "list" :> "v2" - :> ReqBody '[Servant.JSON] ListConversationsV2 + :> ReqBody '[Servant.JSON] ListConversations :> Post '[Servant.JSON] ConversationsResponse, -- This endpoint can lead to the following events being sent: -- - ConvCreate event to members diff --git a/libs/wire-api/test/golden/testObject_ListConversationsV2_1.json b/libs/wire-api/test/golden/testObject_ListConversations_1.json similarity index 100% rename from libs/wire-api/test/golden/testObject_ListConversationsV2_1.json rename to libs/wire-api/test/golden/testObject_ListConversations_1.json diff --git a/libs/wire-api/test/unit/Test/Wire/API/Golden/Manual.hs b/libs/wire-api/test/unit/Test/Wire/API/Golden/Manual.hs index e6d9e3cd859..e4edd42411b 100644 --- a/libs/wire-api/test/unit/Test/Wire/API/Golden/Manual.hs +++ b/libs/wire-api/test/unit/Test/Wire/API/Golden/Manual.hs @@ -27,7 +27,7 @@ import Test.Wire.API.Golden.Manual.ConversationPagingState import Test.Wire.API.Golden.Manual.ConversationsResponse import Test.Wire.API.Golden.Manual.FeatureConfigEvent import Test.Wire.API.Golden.Manual.GetPaginatedConversationIds -import Test.Wire.API.Golden.Manual.ListConversationsV2 +import Test.Wire.API.Golden.Manual.ListConversations import Test.Wire.API.Golden.Manual.QualifiedUserClientPrekeyMap import Test.Wire.API.Golden.Manual.UserClientPrekeyMap import Test.Wire.API.Golden.Manual.UserIdList @@ -96,9 +96,9 @@ tests = [ (testObject_UserIdList_1, "testObject_UserIdList_1.json"), (testObject_UserIdList_2, "testObject_UserIdList_2.json") ], - testGroup "ListConversationsV2" $ + testGroup "ListConversations" $ testObjects - [(testObject_ListConversationsV2_1, "testObject_ListConversationsV2_1.json")], + [(testObject_ListConversations_1, "testObject_ListConversations_1.json")], testGroup "ConversationsResponse" $ testObjects [(testObject_ConversationsResponse_1, "testObject_ConversationsResponse_1.json")] ] diff --git a/libs/wire-api/test/unit/Test/Wire/API/Golden/Manual/ListConversationsV2.hs b/libs/wire-api/test/unit/Test/Wire/API/Golden/Manual/ListConversations.hs similarity index 84% rename from libs/wire-api/test/unit/Test/Wire/API/Golden/Manual/ListConversationsV2.hs rename to libs/wire-api/test/unit/Test/Wire/API/Golden/Manual/ListConversations.hs index 6cac2a29ca9..c10a79ddfd5 100644 --- a/libs/wire-api/test/unit/Test/Wire/API/Golden/Manual/ListConversationsV2.hs +++ b/libs/wire-api/test/unit/Test/Wire/API/Golden/Manual/ListConversations.hs @@ -15,7 +15,7 @@ -- You should have received a copy of the GNU Affero General Public License along -- with this program. If not, see . -module Test.Wire.API.Golden.Manual.ListConversationsV2 where +module Test.Wire.API.Golden.Manual.ListConversations where import Data.Domain (Domain (Domain)) import Data.Id (Id (Id)) @@ -23,11 +23,11 @@ import Data.Qualified (Qualified (Qualified)) import Data.Range (unsafeRange) import qualified Data.UUID as UUID import Imports -import Wire.API.Conversation (ListConversationsV2 (..)) +import Wire.API.Conversation (ListConversations (..)) -testObject_ListConversationsV2_1 :: ListConversationsV2 -testObject_ListConversationsV2_1 = - ListConversationsV2 +testObject_ListConversations_1 :: ListConversations +testObject_ListConversations_1 = + ListConversations ( unsafeRange [ Qualified (Id (fromJust (UUID.fromString "00000018-0000-0020-0000-000e00000002"))) (Domain "domain.example.com"), Qualified (Id (fromJust (UUID.fromString "00000018-0000-0020-0000-111111111112"))) (Domain "domain2.example.com") diff --git a/libs/wire-api/wire-api.cabal b/libs/wire-api/wire-api.cabal index b85340b9ba8..d76a81d602c 100644 --- a/libs/wire-api/wire-api.cabal +++ b/libs/wire-api/wire-api.cabal @@ -4,7 +4,7 @@ cabal-version: 1.12 -- -- see: https://github.com/sol/hpack -- --- hash: 4ba12caf3f3efd379bd7183a7661ac527d4da4072b7d92dd240af982bdab27de +-- hash: c6591983c73573c4734c452218e0831333768e896f0ab08718ba9f2c6b110567 name: wire-api version: 0.1.0 @@ -412,7 +412,7 @@ test-suite wire-api-tests Test.Wire.API.Golden.Manual.ConvIdsPage Test.Wire.API.Golden.Manual.FeatureConfigEvent Test.Wire.API.Golden.Manual.GetPaginatedConversationIds - Test.Wire.API.Golden.Manual.ListConversationsV2 + Test.Wire.API.Golden.Manual.ListConversations Test.Wire.API.Golden.Manual.QualifiedUserClientPrekeyMap Test.Wire.API.Golden.Manual.UserClientPrekeyMap Test.Wire.API.Golden.Manual.UserIdList diff --git a/services/galley/src/Galley/API/Public.hs b/services/galley/src/Galley/API/Public.hs index 1c7f9eb1963..a5422585473 100644 --- a/services/galley/src/Galley/API/Public.hs +++ b/services/galley/src/Galley/API/Public.hs @@ -84,7 +84,6 @@ servantSitemap = GalleyAPI.getConversations = Query.getConversations, GalleyAPI.getConversationByReusableCode = Query.getConversationByReusableCode, GalleyAPI.listConversations = Query.listConversations, - GalleyAPI.listConversationsV2 = Query.listConversationsV2, GalleyAPI.createGroupConversation = Create.createGroupConversation, GalleyAPI.createSelfConversation = Create.createSelfConversation, GalleyAPI.createOne2OneConversation = Create.createOne2OneConversation, diff --git a/services/galley/src/Galley/API/Query.hs b/services/galley/src/Galley/API/Query.hs index cd7a495ff5a..bf41875349b 100644 --- a/services/galley/src/Galley/API/Query.hs +++ b/services/galley/src/Galley/API/Query.hs @@ -25,7 +25,6 @@ module Galley.API.Query conversationIdsPageFrom, getConversations, listConversations, - listConversationsV2, iterateConversations, getLocalSelf, internalGetMemberH, @@ -288,54 +287,8 @@ getConversationsInternal user mids mstart msize = do | Data.isConvDeleted c = Data.deleteConversation (Data.convId c) >> pure False | otherwise = pure True --- | Deprecated. FUTUREWORK(federation): Delete this endpoint -listConversations :: UserId -> Public.ListConversations -> Galley (Public.ConversationList Public.Conversation) -listConversations user (Public.ListConversations mIds qstart msize) = do - localDomain <- viewFederationDomain - when (isJust mIds && isJust qstart) $ - throwM (invalidPayload "'start' and 'qualified_ids' are mutually exclusive") - (localMore, localConvIds, remoteConvIds) <- case mIds of - Just xs -> do - let (remoteConvIds, localIds) = partitionRemoteOrLocalIds' localDomain (toList xs) - (localMore, localConvIds) <- getIdsAndMore localIds - pure (localMore, localConvIds, remoteConvIds) - Nothing -> do - (localMore, localConvIds) <- getAll (localstart localDomain) - remoteConvIds <- Data.conversationsRemote user - pure (localMore, localConvIds, remoteConvIds) - - localInternalConversations <- - Data.localConversations localConvIds - >>= filterM removeDeleted - >>= filterM (pure . isMember user . Data.convLocalMembers) - localConversations <- mapM (Mapping.conversationView user) localInternalConversations - - remoteConversations <- getRemoteConversations user remoteConvIds - let allConvs = localConversations <> remoteConversations - pure $ Public.ConversationList allConvs localMore - where - localstart localDomain = case qstart of - Just start | qDomain start == localDomain -> Just (qUnqualified start) - _ -> Nothing - - size = fromMaybe (toRange (Proxy @32)) msize - - getIdsAndMore :: [ConvId] -> Galley (Bool, [ConvId]) - getIdsAndMore ids = (False,) <$> Data.localConversationIdsOf user ids - - getAll :: Maybe ConvId -> Galley (Bool, [ConvId]) - getAll mstart = do - r <- Data.conversationIdsFrom user mstart (rcast size) - let hasMore = Data.resultSetType r == Data.ResultSetTruncated - pure (hasMore, Data.resultSetResult r) - - removeDeleted :: Data.Conversation -> Galley Bool - removeDeleted c - | Data.isConvDeleted c = Data.deleteConversation (Data.convId c) >> pure False - | otherwise = pure True - -listConversationsV2 :: UserId -> Public.ListConversationsV2 -> Galley Public.ConversationsResponse -listConversationsV2 user (Public.ListConversationsV2 ids) = do +listConversations :: UserId -> Public.ListConversations -> Galley Public.ConversationsResponse +listConversations user (Public.ListConversations ids) = do localDomain <- viewFederationDomain let (remoteIds, localIds) = partitionRemoteOrLocalIds' localDomain (fromRange ids) diff --git a/services/galley/test/integration/API.hs b/services/galley/test/integration/API.hs index fb34dc78b05..2bcbf2ba80f 100644 --- a/services/galley/test/integration/API.hs +++ b/services/galley/test/integration/API.hs @@ -120,9 +120,7 @@ tests s = test s "metrics" metrics, test s "create conversation" postConvOk, test s "get empty conversations" getConvsOk, - test s "list-conversations empty" listConvsOk, test s "get conversations by ids" getConvsOk2, - test s "list-conversations by ids" listConvsOk2, test s "fail to get >500 conversations" getConvsFailMaxSize, test s "get conversation ids" getConvIdsOk, test s "get conversation ids v2" listConvIdsOk, @@ -131,7 +129,6 @@ tests s = test s "paginate through /conversations/list-ids - page ending at locals and remote domain" paginateConvListIdsPageEndingAtLocalsAndDomain, test s "fail to get >1000 conversation ids" getConvIdsFailMaxSize, test s "page through conversations" getConvsPagingOk, - test s "page through list-conversations (local conversations only)" listConvsPagingOk, test s "fail to create conversation when not connected" postConvFailNotConnected, test s "fail to create conversation with qualified users when not connected" postConvQualifiedFailNotConnected, test s "M:N conversation creation with N - 1 invitees should be allowed" postConvLimitOk, @@ -167,7 +164,6 @@ tests s = test s "get conversations/:domain/:cnv - remote" testGetQualifiedRemoteConv, test s "get conversations/:domain/:cnv - remote, not found" testGetQualifiedRemoteConvNotFound, test s "get conversations/:domain/:cnv - remote, not found on remote" testGetQualifiedRemoteConvNotFoundOnRemote, - test s "post list-conversations" testListRemoteConvs, test s "post conversations/list/v2" testBulkGetQualifiedConvs, test s "add non-existing remote members" testAddRemoteMemberFailure, test s "add deleted remote members" testAddDeletedRemoteUser, @@ -1160,14 +1156,6 @@ getConvsOk = do const 200 === statusCode const [toUUID usr] === map (toUUID . qUnqualified . cnvQualifiedId) . decodeConvList --- same test as getConvsOk, but using the listConversations endpoint -listConvsOk :: TestM () -listConvsOk = do - usr <- randomUser - listAllConvs usr !!! do - const 200 === statusCode - const [toUUID usr] === map (toUUID . qUnqualified . cnvQualifiedId) . decodeConvList - getConvsOk2 :: TestM () getConvsOk2 = do [alice, bob] <- randomUsers 2 @@ -1203,44 +1191,6 @@ getConvsOk2 = do (Just []) ((\c -> cmOthers (cnvMembers c) \\ cmOthers (cnvMembers expected)) <$> actual) --- same test as getConvsOk2, but using the listConversations endpoint -listConvsOk2 :: TestM () -listConvsOk2 = do - [alice, bob] <- randomUsers 2 - connectUsers alice (singleton bob) - -- create & get one2one conv - cnv1 <- responseJsonUnsafeWithMsg "conversation" <$> postO2OConv alice bob (Just "gossip1") - let req1 = ListConversations (Just (cnvQualifiedId cnv1 :| [])) Nothing Nothing - listConvs alice req1 !!! do - const 200 === statusCode - const (Just [cnvQualifiedId cnv1]) === fmap (map cnvQualifiedId . convList) . responseJsonUnsafe - -- create & get group conv - carl <- randomUser - connectUsers alice (singleton carl) - cnv2 <- responseJsonUnsafeWithMsg "conversation" <$> postConv alice [bob, carl] (Just "gossip2") [] Nothing Nothing - let req2 = ListConversations (Just (cnvQualifiedId cnv2 :| [])) Nothing Nothing - listConvs alice req2 !!! do - const 200 === statusCode - const (Just [cnvQualifiedId cnv2]) === fmap (map cnvQualifiedId . convList) . responseJsonUnsafe - -- get both - rs <- listAllConvs alice responseJsonUnsafe rs - let c1 = convs >>= find ((== cnvQualifiedId cnv1) . cnvQualifiedId) - let c2 = convs >>= find ((== cnvQualifiedId cnv2) . cnvQualifiedId) - liftIO . forM_ [(cnv1, c1), (cnv2, c2)] $ \(expected, actual) -> do - assertEqual - "name mismatch" - (Just $ cnvName expected) - (cnvName <$> actual) - assertEqual - "self member mismatch" - (Just . cmSelf $ cnvMembers expected) - (cmSelf . cnvMembers <$> actual) - assertEqual - "other members mismatch" - (Just []) - ((\c -> cmOthers (cnvMembers c) \\ cmOthers (cnvMembers expected)) <$> actual) - getConvsFailMaxSize :: TestM () getConvsFailMaxSize = do usr <- randomUser @@ -1453,35 +1403,6 @@ getConvsPagingOk = do liftIO $ assertBool "getConvIds /= getConvs" (ids1 == ids3) return $ ids1 >>= listToMaybe . reverse --- same test as getConvsPagingOk, but using the listConversations endpoint --- (only tests pagination behaviour for local conversations) --- FUTUREWORK: pagination for remote conversations -listConvsPagingOk :: TestM () -listConvsPagingOk = do - [ally, bill, carl] <- randomUsers 3 - connectUsers ally (list1 bill [carl]) - replicateM_ 11 $ postConv ally [bill, carl] (Just "gossip") [] Nothing Nothing - walk ally [3, 3, 3, 3, 2] -- 11 (group) + 2 (1:1) + 1 (self) - walk bill [3, 3, 3, 3, 1] -- 11 (group) + 1 (1:1) + 1 (self) - walk carl [3, 3, 3, 3, 1] -- 11 (group) + 1 (1:1) + 1 (self) - where - walk :: Foldable t => UserId -> t Int -> TestM () - walk u = foldM_ (next u 3) Nothing - next :: UserId -> Int32 -> Maybe ConvId -> Int -> TestM (Maybe ConvId) - next u step start n = do - -- FUTUREWORK: support an endpoint to get qualified conversation IDs - -- (without all the conversation metadata) - r1 <- getConvIds u (Right <$> start) (Just step) responseJsonUnsafe r1 - liftIO $ assertEqual "unexpected length (getConvIds)" (Just n) (length <$> ids1) - localDomain <- viewFederationDomain - let requestBody = ListConversations Nothing (flip Qualified localDomain <$> start) (Just (unsafeRange step)) - r2 <- listConvs u requestBody responseJsonUnsafe r2 - liftIO $ assertEqual "unexpected length (getConvs)" (Just n) (length <$> ids3) - liftIO $ assertBool "getConvIds /= getConvs" (ids1 == ids3) - return $ ids1 >>= listToMaybe . reverse - postConvFailNotConnected :: TestM () postConvFailNotConnected = do alice <- randomUser @@ -1971,42 +1892,7 @@ testGetQualifiedRemoteConvNotFoundOnRemote = do const 404 === statusCode const (Just "no-conversation") === view (at "label") . responseJsonUnsafe @Object -testListRemoteConvs :: TestM () -testListRemoteConvs = do - -- alice on local domain - -- bob and the conversation on the remote domain - aliceQ <- randomQualifiedUser - let alice = qUnqualified aliceQ - bobId <- randomId - convId <- randomId - let remoteDomain = Domain "far-away.example.com" - bobQ = Qualified bobId remoteDomain - remoteConvId = Qualified convId remoteDomain - - let aliceAsOtherMember = OtherMember aliceQ Nothing roleNameWireAdmin - mockConversation = mkConv remoteConvId alice roleNameWireAdmin [aliceAsOtherMember] - remoteConversationResponse = GetConversationsResponse [mockConversation] - opts <- view tsGConf - - registerRemoteConv remoteConvId bobQ Nothing (Set.fromList [aliceAsOtherMember]) - - -- FUTUREWORK: Do this test with more than one remote domains - -- test POST /list-conversations - (respAll, _) <- - withTempMockFederator - opts - remoteDomain - (const remoteConversationResponse) - (listAllConvs alice) - convs <- responseJsonUnsafe <$> (pure respAll pure . F.OutwardResponseError $ F.OutwardError F.DiscoveryFailed "discovery failed" _ -> assertFailure $ "Unrecognized domain: " <> show fedReq ) - (listConvsV2 alice req) + (listConvs alice req) convs <- responseJsonUnsafe <$> (pure respAll UserId -> m ResponseLBS -listAllConvs u = do - g <- viewGalley - post $ - g - . path "/list-conversations" - . zUser u - . zConn "conn" - . zType "access" - . json emptyObject - listConvs :: (MonadIO m, MonadHttp m, HasGalley m) => UserId -> ListConversations -> m ResponseLBS listConvs u req = do - -- when using servant-client (pending #1605), this would become: - -- galleyClient <- view tsGalleyClient - -- res :: Public.ConversationList Public.Conversation <- listConversations galleyClient req - g <- viewGalley - post $ - g - . path "/list-conversations" - . zUser u - . zConn "conn" - . zType "access" - . json req - -listConvsV2 :: (MonadIO m, MonadHttp m, HasGalley m) => UserId -> ListConversationsV2 -> m ResponseLBS -listConvsV2 u req = do g <- viewGalley post $ g From 992959dc9fc928c23cfe9a05fe5eda41c2621dcd Mon Sep 17 00:00:00 2001 From: Paolo Capriotti Date: Wed, 6 Oct 2021 17:09:49 +0200 Subject: [PATCH 2/3] Remove /list-conversations from nginx conf --- charts/nginz/values.yaml | 3 --- deploy/services-demo/conf/nginz/nginx-docker.conf | 5 ----- deploy/services-demo/conf/nginz/nginx.conf | 5 ----- 3 files changed, 13 deletions(-) diff --git a/charts/nginz/values.yaml b/charts/nginz/values.yaml index 3773dd2aed2..2d006ddb7b9 100644 --- a/charts/nginz/values.yaml +++ b/charts/nginz/values.yaml @@ -304,9 +304,6 @@ nginx_conf: envs: - all doc: true - - path: ~* ^/list-conversations$ - envs: - - all - path: ~* ^/teams$ envs: - all diff --git a/deploy/services-demo/conf/nginz/nginx-docker.conf b/deploy/services-demo/conf/nginz/nginx-docker.conf index c674cdd4ac4..9fdd32baf84 100644 --- a/deploy/services-demo/conf/nginz/nginx-docker.conf +++ b/deploy/services-demo/conf/nginz/nginx-docker.conf @@ -253,11 +253,6 @@ http { proxy_pass http://galley; } - location /list-conversations { - include common_response_with_zauth.conf; - proxy_pass http://galley; - } - location ~* ^/conversations/([^/]*)/otr/messages { include common_response_with_zauth.conf; proxy_pass http://galley; diff --git a/deploy/services-demo/conf/nginz/nginx.conf b/deploy/services-demo/conf/nginz/nginx.conf index 5d577caed68..543dc2d8c3c 100644 --- a/deploy/services-demo/conf/nginz/nginx.conf +++ b/deploy/services-demo/conf/nginz/nginx.conf @@ -313,11 +313,6 @@ http { proxy_pass http://galley; } - location /list-conversations { - include common_response_with_zauth.conf; - proxy_pass http://galley; - } - location ~* ^/conversations/([^/]*)/otr/messages { include common_response_with_zauth.conf; proxy_pass http://galley; From 373ba61be3635222bf6c2afc4fc66e96b0ab84be Mon Sep 17 00:00:00 2001 From: Paolo Capriotti Date: Thu, 7 Oct 2021 10:39:23 +0200 Subject: [PATCH 3/3] Remove use of /list-conversations from End2end --- .../test/integration/Federation/End2end.hs | 17 ++++++-- services/brig/test/integration/Util.hs | 41 ++++++++++--------- 2 files changed, 34 insertions(+), 24 deletions(-) diff --git a/services/brig/test/integration/Federation/End2end.hs b/services/brig/test/integration/Federation/End2end.hs index 39961ea2478..fc9f39ccf15 100644 --- a/services/brig/test/integration/Federation/End2end.hs +++ b/services/brig/test/integration/Federation/End2end.hs @@ -37,6 +37,7 @@ import Data.List1 as List1 import qualified Data.Map as Map import qualified Data.ProtoLens as Protolens import Data.Qualified +import Data.Range (checked) import qualified Data.Set as Set import Federation.Util (generateClientPrekeys, getConvQualified) import Gundeck.Types.Notification (ntfTransient) @@ -52,6 +53,7 @@ import Wire.API.Conversation import Wire.API.Conversation.Role (roleNameWireAdmin) import Wire.API.Event.Conversation import Wire.API.Message +import Wire.API.Routes.MultiTablePaging import Wire.API.User (ListUsersQuery (ListUsersByIds)) import Wire.API.User.Client @@ -414,10 +416,17 @@ testListConversations brig1 brig2 galley1 galley2 = do -- From Alice's point of view -- both conversations should show her as the self member and bob as Othermember. let expected = cnv1 - rs <- listAllConvs galley1 (userId alice) responseJsonUnsafe rs - let c1 = cs >>= find ((== cnvQualifiedId cnv1) . cnvQualifiedId) - let c2 = cs >>= find ((== cnvQualifiedId cnv2) . cnvQualifiedId) + rs <- listConvIdsFirstPage galley1 (userId alice) assertFailure "too many conversations" + Just r -> pure r + (cs :: [Conversation]) <- + (fmap crFound . responseJsonError) + =<< listConvs galley1 (userId alice) cids do assertEqual "self member mismatch" diff --git a/services/brig/test/integration/Util.hs b/services/brig/test/integration/Util.hs index e5840321566..cc9963d6c7e 100644 --- a/services/brig/test/integration/Util.hs +++ b/services/brig/test/integration/Util.hs @@ -41,7 +41,6 @@ import Control.Monad.Catch (MonadCatch, MonadMask) import Control.Retry import Data.Aeson hiding (json) import Data.Aeson.Lens (key, _Integral, _JSON, _String) -import Data.Aeson.Types (emptyObject) import qualified Data.Aeson.Types as Aeson import qualified Data.ByteString as BS import Data.ByteString.Char8 (pack) @@ -53,6 +52,7 @@ import Data.Id import Data.List1 (List1) import qualified Data.List1 as List1 import Data.Misc (PlainTextPassword (..)) +import Data.Proxy import Data.Qualified import Data.Range import qualified Data.Text as Text @@ -72,10 +72,10 @@ import qualified Test.Tasty.Cannon as WS import Test.Tasty.HUnit import qualified UnliftIO.Async as Async import Util.AWS -import Wire.API.Conversation (ListConversations, NewConv (..), NewConvUnmanaged (..)) -import Wire.API.Conversation.Member (Member (..)) +import Wire.API.Conversation import Wire.API.Conversation.Role (roleNameWireAdmin) import qualified Wire.API.Federation.API.Brig as FedBrig +import Wire.API.Routes.MultiTablePaging type Brig = Request -> Request @@ -584,28 +584,29 @@ createConversation galley zusr usersToAdd = do . zConn "conn" . json conv --- (should be) equivalent to --- listConvs u (ListConversations [] Nothing Nothing) -listAllConvs :: (MonadIO m, MonadHttp m) => Galley -> UserId -> m ResponseLBS -listAllConvs g u = do +listConvIdsFirstPage :: (MonadIO m, MonadHttp m) => Galley -> UserId -> m ResponseLBS +listConvIdsFirstPage galley zusr = do + let req = GetMultiTablePageRequest (toRange (Proxy @1000)) Nothing :: GetPaginatedConversationIds post $ - g - . path "/list-conversations" - . zUser u + galley + . path "/conversations/list-ids" + . zUser zusr . zConn "conn" - . json emptyObject + . json req -listConvs :: (MonadIO m, MonadHttp m) => Galley -> UserId -> ListConversations -> m ResponseLBS -listConvs g u req = do - -- when using servant-client (pending #1605), this would become: - -- galleyClient <- view tsGalleyClient - -- res :: Public.ConversationList Public.Conversation <- listConversations galleyClient req +listConvs :: + (MonadIO m, MonadHttp m) => + Galley -> + UserId -> + Range 1 1000 [Qualified ConvId] -> + m ResponseLBS +listConvs galley zusr convs = do post $ - g - . path "/list-conversations" - . zUser u + galley + . path "/conversations/list/v2" + . zUser zusr . zConn "conn" - . json req + . json (ListConversations convs) isMember :: Galley -> UserId -> ConvId -> (MonadIO m, MonadHttp m) => m Bool isMember g usr cnv = do