Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove `POST /list-conversations` endpoint.
3 changes: 0 additions & 3 deletions charts/nginz/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,6 @@ nginx_conf:
envs:
- all
doc: true
- path: ~* ^/list-conversations$
envs:
- all
- path: ~* ^/teams$
envs:
- all
Expand Down
5 changes: 0 additions & 5 deletions deploy/services-demo/conf/nginz/nginx-docker.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 0 additions & 5 deletions deploy/services-demo/conf/nginz/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
27 changes: 4 additions & 23 deletions libs/wire-api/src/Wire/API/Conversation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ module Wire.API.Conversation
ConversationCoverView (..),
ConversationList (..),
ListConversations (..),
ListConversationsV2 (..),
GetPaginatedConversationIds,
pattern GetPaginatedConversationIds,
ConvIdsPage,
Expand Down Expand Up @@ -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
Expand Down
19 changes: 5 additions & 14 deletions libs/wire-api/src/Wire/API/Routes/Public/Galley.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions libs/wire-api/test/unit/Test/Wire/API/Golden/Manual.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")]
]
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@
-- You should have received a copy of the GNU Affero General Public License along
-- with this program. If not, see <https://www.gnu.org/licenses/>.

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))
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")
Expand Down
4 changes: 2 additions & 2 deletions libs/wire-api/wire-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion services/galley/src/Galley/API/Public.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
51 changes: 2 additions & 49 deletions services/galley/src/Galley/API/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ module Galley.API.Query
conversationIdsPageFrom,
getConversations,
listConversations,
listConversationsV2,
iterateConversations,
getLocalSelf,
internalGetMemberH,
Expand Down Expand Up @@ -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)
Expand Down
Loading