Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
797b5a1
Break POST /list-conversations API and adapt code
akshaymankar Aug 10, 2021
28e8ddd
Restore old endpoint, create v2
akshaymankar Aug 11, 2021
c0a5707
Ormolu
akshaymankar Aug 11, 2021
72e2ed8
Test the right endpoint!
akshaymankar Aug 11, 2021
8e957ba
Limit number of Ids to 1000
akshaymankar Aug 11, 2021
efbd7c3
Add a TODO to verify old code
akshaymankar Aug 11, 2021
d92c44b
Reorganize tests
akshaymankar Aug 11, 2021
d69d5ee
Also test getting local conversation
akshaymankar Aug 11, 2021
80a21f1
Test with multiple remotes
akshaymankar Aug 11, 2021
4d70f2c
Ensure no unauthorized access to remote conversation metadata
akshaymankar Aug 11, 2021
8963b33
Ensure local not founds are reported
akshaymankar Aug 12, 2021
d79db08
Remote tackled TODO
akshaymankar Aug 12, 2021
91d6783
Ensure remote not founds are reported
akshaymankar Aug 12, 2021
bdea5d0
Ensure failed conversation fetches are logged and reported
akshaymankar Aug 12, 2021
56b6e27
Ormolu
akshaymankar Aug 17, 2021
046ada5
Remove tackled TODO
akshaymankar Aug 17, 2021
f3f7958
Remove tackled FUTUREWORK
akshaymankar Aug 17, 2021
e688135
Add FUTUREWORK to deal with backendds being out of sync
akshaymankar Aug 17, 2021
4fad988
Fix endpoint path in comment
akshaymankar Aug 17, 2021
bab7fc0
Simplify checking membership
akshaymankar Aug 17, 2021
414b282
Update changelog-draft
akshaymankar Aug 19, 2021
b6c5386
Remove TODO, in favour of solving it separately
akshaymankar Aug 19, 2021
548499f
Extract helper for concurrent monadic partitioning
akshaymankar Aug 19, 2021
ecb39e4
Fix docs for the integration test
akshaymankar Aug 19, 2021
5184128
Ormolu
akshaymankar Aug 19, 2021
28e360b
Simplify bulk verifying membership of a user in a list of convs
akshaymankar Aug 30, 2021
d39308e
Replace conversationIdsOf with localConverstaionIdsOf
akshaymankar Aug 30, 2021
8ef391d
Apply suggestions from code review
akshaymankar Aug 30, 2021
4ebd9e2
Apply suggestions from code review
akshaymankar Aug 30, 2021
f256c32
Merge branch 'develop' into akshaymankar/list-convs-only-by-id
akshaymankar Aug 30, 2021
0c9b788
Merge branch 'develop' into akshaymankar/list-convs-only-by-id
akshaymankar Sep 1, 2021
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
4 changes: 4 additions & 0 deletions CHANGELOG-draft.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ THIS FILE ACCUMULATES THE RELEASE NOTES FOR THE UPCOMING RELEASE.

## API Changes

* Add `POST /conversations/list/v2` (#1703)
* Deprecate `POST /list-conversations` (#1703)

## Features

## Bug fixes and other updates
Expand All @@ -40,3 +43,4 @@ THIS FILE ACCUMULATES THE RELEASE NOTES FOR THE UPCOMING RELEASE.
## Internal changes

* The update conversation membership federation endpoint takes OriginDomainHeader (#1719)
* Added new endpoint to allow fetching conversation metadata by qualified ids (#1703)
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ data FederationError
| FederationNotImplemented
| FederationNotConfigured
| FederationCallFailure FederationClientFailure
deriving (Show, Eq)

data FederationClientFailure = FederationClientFailure
{ fedFailDomain :: Domain,
Expand Down
1 change: 1 addition & 0 deletions libs/wire-api/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ library:
- servant-server
- servant-swagger
- schema-profunctor
- singletons
- sop-core
- string-conversions
- swagger >=0.1
Expand Down
42 changes: 39 additions & 3 deletions libs/wire-api/src/Wire/API/Conversation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ module Wire.API.Conversation
ConversationCoverView (..),
ConversationList (..),
ListConversations (..),
ListConversationsV2 (..),
GetPaginatedConversationIds (..),
ConversationPagingState (..),
ConversationPagingTable (..),
ConvIdsPage (..),
ConversationsResponse (..),

-- * Conversation properties
Access (..),
Expand Down Expand Up @@ -87,9 +89,10 @@ import Data.List1
import Data.Misc
import Data.Proxy (Proxy (Proxy))
import Data.Qualified (Qualified (qUnqualified), deprecatedSchema)
import Data.Range (Range, toRange)
import Data.Range (Range, fromRange, rangedSchema, toRange)
import Data.Schema
import qualified Data.Set as Set
import Data.Singletons (sing)
import Data.String.Conversions (cs)
import qualified Data.Swagger as S
import qualified Data.Swagger.Build.Api as Doc
Expand Down Expand Up @@ -342,8 +345,6 @@ instance ToSchema GetPaginatedConversationIds where
<$> gpciPagingState .= optFieldWithDocModifier "paging_state" Nothing addPagingStateDoc schema
<*> gpciSize .= (fieldWithDocModifier "size" addSizeDoc schema <|> pure (toRange (Proxy @1000)))

-- | Used on the POST /list-conversations endpoint
-- FUTUREWORK: add to golden tests (how to generate them?)
data ListConversations = ListConversations
{ lQualifiedIds :: Maybe (NonEmpty (Qualified ConvId)),
lStartId :: Maybe (Qualified ConvId),
Expand All @@ -362,6 +363,41 @@ instance ToSchema ListConversations where
<*> lStartId .= optField "start_id" Nothing schema
<*> lSize .= optField "size" Nothing schema

-- | Used on the POST /conversations/list/v2 endpoint
newtype ListConversationsV2 = ListConversationsV2
{ lcQualifiedIds :: Range 1 1000 [Qualified ConvId]
}
deriving stock (Eq, Show, Generic)
deriving (FromJSON, ToJSON, S.ToSchema) via Schema ListConversationsV2

instance ToSchema ListConversationsV2 where
schema =
objectWithDocModifier
"ListConversations"
(description ?~ "A request to list some of a user's conversations, including remote ones. Maximum 1000 qualified conversation IDs")
$ ListConversationsV2
<$> (fromRange . lcQualifiedIds) .= field "qualified_ids" (rangedSchema sing sing (array schema))

data ConversationsResponse = ConversationsResponse
{ crFound :: [Conversation],
crNotFound :: [Qualified ConvId],
crFailed :: [Qualified ConvId]
}
deriving stock (Eq, Show)
deriving (FromJSON, ToJSON, S.ToSchema) via Schema ConversationsResponse

instance ToSchema ConversationsResponse where
schema =
let notFoundDoc = description ?~ "These conversations either don't exist or are deleted."
failedDoc = description ?~ "The server failed to fetch these conversations, most likely due to network issues while contacting a remote server"
in objectWithDocModifier
"ConversationsResponse"
(description ?~ "Response object for getting metadata of a list of conversations")
$ ConversationsResponse
<$> crFound .= field "found" (array schema)
<*> crNotFound .= fieldWithDocModifier "not_found" notFoundDoc (array schema)
<*> crFailed .= fieldWithDocModifier "failed" failedDoc (array schema)

--------------------------------------------------------------------------------
-- Conversation properties

Expand Down
17 changes: 15 additions & 2 deletions libs/wire-api/src/Wire/API/Routes/Public/Galley.hs
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,25 @@ data Api routes = Api
:> Get '[Servant.JSON] (Public.ConversationList Public.Conversation),
listConversations ::
routes
:- Summary "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. WIP: Size parameter is not yet honoured for remote conversations."
:- 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] Public.ListConversations
:> Post '[Servant.JSON] (Public.ConversationList Public.Conversation),
listConversationsV2 ::
routes
:- Summary "Get conversation metadata for a list of conversation ids"
:> ZUser
:> "conversations"
:> "list"
:> "v2"
:> ReqBody '[Servant.JSON] Public.ListConversationsV2
:> Post '[Servant.JSON] Public.ConversationsResponse,
-- This endpoint can lead to the following events being sent:
-- - ConvCreate event to members
getConversationByReusableCode ::
Expand Down

This file was deleted.

107 changes: 107 additions & 0 deletions libs/wire-api/test/golden/testObject_ConversationsResponse_1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
"found": [
{
"access": [],
"creator": "00000001-0000-0001-0000-000200000001",
"access_role": "private",
"members": {
"self": {
"hidden_ref": "",
"status": 0,
"service": null,
"otr_muted_ref": null,
"conversation_role": "rhhdzf0j0njilixx0g0vzrp06b_5us",
"status_time": "1970-01-01T00:00:00.000Z",
"hidden": false,
"status_ref": "0.0",
"id": "00000001-0000-0001-0000-000100000000",
"otr_archived": false,
"otr_muted_status": null,
"otr_muted": true,
"otr_archived_ref": ""
},
"others": []
},
"qualified_id": {
"domain": "golden.example.com",
"id": "00000001-0000-0000-0000-000000000000"
},
"name": " 0",
"team": "00000001-0000-0001-0000-000100000002",
"id": "00000001-0000-0000-0000-000000000000",
"type": 2,
"receipt_mode": -2,
"last_event_time": "1970-01-01T00:00:00.000Z",
"message_timer": null,
"last_event": "0.0"
},
{
"access": [
"invite",
"invite",
"code",
"link",
"invite",
"private",
"link",
"code",
"code",
"link",
"private",
"invite"
],
"creator": "00000000-0000-0000-0000-000200000001",
"access_role": "non_activated",
"members": {
"self": {
"hidden_ref": "",
"status": 0,
"service": null,
"otr_muted_ref": null,
"conversation_role": "9b2d3thyqh4ptkwtq2n2v9qsni_ln1ca66et_z8dlhfs9oamp328knl3rj9kcj",
"status_time": "1970-01-01T00:00:00.000Z",
"hidden": true,
"status_ref": "0.0",
"id": "00000000-0000-0001-0000-000100000001",
"otr_archived": false,
"otr_muted_status": -1,
"otr_muted": true,
"otr_archived_ref": null
},
"others": []
},
"qualified_id": {
"domain": "golden.example.com",
"id": "00000000-0000-0000-0000-000000000002"
},
"name": "",
"team": "00000000-0000-0001-0000-000200000000",
"id": "00000000-0000-0000-0000-000000000002",
"type": 1,
"receipt_mode": 2,
"last_event_time": "1970-01-01T00:00:00.000Z",
"message_timer": 1319272593797015,
"last_event": "0.0"
}
],
"not_found": [
{
"domain": "golden.example.com",
"id": "00000018-0000-0020-0000-000e00000002"
},
{
"domain": "golden2.example.com",
"id": "00000018-0000-0020-0000-111111111112"
}
],
"failed": [
{
"domain": "golden.example.com",
"id": "00000018-4444-0020-0000-000e00000002"
},
{
"domain": "golden3.example.com",
"id": "99999999-0000-0020-0000-111111111112"
}
]
}
12 changes: 12 additions & 0 deletions libs/wire-api/test/golden/testObject_ListConversationsV2_1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"qualified_ids": [
{
"domain": "domain.example.com",
"id": "00000018-0000-0020-0000-000e00000002"
},
{
"domain": "domain2.example.com",
"id": "00000018-0000-0020-0000-111111111112"
}
]
}
4 changes: 0 additions & 4 deletions libs/wire-api/test/unit/Test/Wire/API/Golden/FromJSON.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import Test.Wire.API.Golden.Generated.NewConvUnmanaged_user
import Test.Wire.API.Golden.Generated.NewOtrMessage_user
import Test.Wire.API.Golden.Generated.RmClient_user
import Test.Wire.API.Golden.Generated.SimpleMember_user
import Test.Wire.API.Golden.Manual.ListConversations
import Test.Wire.API.Golden.Runner
import Wire.API.Conversation (Conversation)
import Wire.API.User.Client (RmClient)
Expand All @@ -49,9 +48,6 @@ tests =
[(testObject_RmClient_user_4, "testObject_RmClient_user_4.json")],
testCase "RmClient failure" $
testFromJSONFailure @RmClient "testObject_RmClient_failure.json",
testCase "ListConversations" $
testFromJSONObjects
[(testObject_ListConversations_1, "testObject_ListConversations_1.json")],
testCase "QualifiedConversationId" $
testFromJSONFailure @Conversation "testObject_Conversation_qualifiedId.json"
]
9 changes: 8 additions & 1 deletion libs/wire-api/test/unit/Test/Wire/API/Golden/Manual.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ import Test.Wire.API.Golden.Manual.ClientCapabilityList
import Test.Wire.API.Golden.Manual.ConvIdsPage
import Test.Wire.API.Golden.Manual.ConversationCoverView
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.QualifiedUserClientPrekeyMap
import Test.Wire.API.Golden.Manual.UserClientPrekeyMap
import Test.Wire.API.Golden.Manual.UserIdList
Expand Down Expand Up @@ -94,5 +96,10 @@ tests =
testObjects
[ (testObject_UserIdList_1, "testObject_UserIdList_1.json"),
(testObject_UserIdList_2, "testObject_UserIdList_2.json")
]
],
testCase "ListConversationsV2" $
testObjects
[(testObject_ListConversationsV2_1, "testObject_ListConversationsV2_1.json")],
testCase "ConversationsResponse" $
testObjects [(testObject_ConversationsResponse_1, "testObject_ConversationsResponse_1.json")]
]
Loading