Skip to content

Commit 69ec6cc

Browse files
committed
WIP
1 parent 2c433da commit 69ec6cc

File tree

9 files changed

+20
-46
lines changed

9 files changed

+20
-46
lines changed

libs/galley-types/src/Galley/Types/IdMapping.hs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ module Galley.Types.IdMapping
2424
)
2525
where
2626

27-
import Data.Aeson
2827
import Data.Coerce (coerce)
2928
import Data.Id (Id, Mapped, Remote)
3029
import Data.Qualified (Qualified)
@@ -42,14 +41,6 @@ newtype PostIdMappingRequest = PostIdMappingRequest
4241
mkPostIdMappingRequest :: Qualified (Id (Remote a)) -> PostIdMappingRequest
4342
mkPostIdMappingRequest = PostIdMappingRequest . coerce
4443

45-
instance ToJSON PostIdMappingRequest where
46-
toJSON (PostIdMappingRequest qualifiedId) =
47-
object ["qualified_id" .= qualifiedId]
48-
49-
instance FromJSON PostIdMappingRequest where
50-
parseJSON = withObject "PostIdMappingRequest" $ \o ->
51-
PostIdMappingRequest <$> o .: "qualified_id"
52-
5344
-- | Response used for inter-service communication between Galley and Brig to ensure that ID
5445
-- mappings discovered in one service are also known in the other.
5546
--
@@ -58,11 +49,3 @@ instance FromJSON PostIdMappingRequest where
5849
newtype PostIdMappingResponse = PostIdMappingResponse
5950
{resMappedId :: Id (Mapped ())}
6051
deriving stock (Eq, Show)
61-
62-
instance ToJSON PostIdMappingResponse where
63-
toJSON (PostIdMappingResponse mappedId) =
64-
object ["mapped_id" .= mappedId]
65-
66-
instance FromJSON PostIdMappingResponse where
67-
parseJSON = withObject "PostIdMappingResponse" $ \o ->
68-
PostIdMappingResponse <$> o .: "mapped_id"

libs/galley-types/test/unit/Test/Galley/Types.hs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ tests =
5353
-- accordingly. Just maintain the property that adding a new feature name will break
5454
-- this test, and force future develpers to consider what permissions they want to set.
5555
assertBool "all covered" (all (roleHasPerm RoleExternalPartner) (ViewTeamFeature <$> [minBound ..])),
56-
testRoundTrip @FeatureFlags,
57-
testRoundTrip @PostIdMappingRequest,
58-
testRoundTrip @PostIdMappingRequest
56+
testRoundTrip @FeatureFlags
5957
]
6058

6159
instance Arbitrary FeatureFlags where

libs/types-common/src/Data/IdMapping.hs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,6 @@ data IdMapping a = IdMapping
5858
}
5959
deriving stock (Eq, Ord, Show)
6060

61-
-- Don't add a FromJSON instance!
62-
-- We don't want to just accept mappings we didn't create ourselves.
63-
instance ToJSON (IdMapping a) where
64-
toJSON IdMapping {_imMappedId, _imQualifiedId} =
65-
Aeson.object
66-
[ "mapped_id" .= _imMappedId,
67-
"qualified_id" .= _imQualifiedId
68-
]
69-
7061
-- | Deterministically hashes a qualified ID to a single UUID
7162
--
7263
-- Note that when using this function to obtain a mapped ID, you should also create

libs/types-common/src/Data/Qualified.hs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ module Data.Qualified
3535
where
3636

3737
import Control.Applicative (optional)
38-
import Data.Aeson (FromJSON, ToJSON, withText)
39-
import qualified Data.Aeson as Aeson
4038
import qualified Data.Attoparsec.ByteString.Char8 as Atto
4139
import Data.Bifunctor (first)
4240
import Data.ByteString.Conversion (FromByteString (parser))
@@ -129,11 +127,11 @@ renderQualifiedId = renderQualified (cs . UUID.toString . toUUID)
129127
mkQualifiedId :: Text -> Either String (Qualified (Id a))
130128
mkQualifiedId = Atto.parseOnly (parser <* Atto.endOfInput) . Text.E.encodeUtf8
131129

132-
instance ToJSON (Qualified (Id a)) where
133-
toJSON = Aeson.String . renderQualifiedId
130+
-- instance ToJSON (Qualified (Id a)) where
131+
-- toJSON = Aeson.String . renderQualifiedId
134132

135-
instance FromJSON (Qualified (Id a)) where
136-
parseJSON = withText "QualifiedUserId" $ either fail pure . mkQualifiedId
133+
-- instance FromJSON (Qualified (Id a)) where
134+
-- parseJSON = withText "QualifiedUserId" $ either fail pure . mkQualifiedId
137135

138136
instance FromHttpApiData (Qualified (Id a)) where
139137
parseUrlPiece = first cs . mkQualifiedId
@@ -149,11 +147,11 @@ renderQualifiedHandle = renderQualified fromHandle
149147
mkQualifiedHandle :: Text -> Either String (Qualified Handle)
150148
mkQualifiedHandle = Atto.parseOnly (parser <* Atto.endOfInput) . Text.E.encodeUtf8
151149

152-
instance ToJSON (Qualified Handle) where
153-
toJSON = Aeson.String . renderQualifiedHandle
150+
-- instance ToJSON (Qualified Handle) where
151+
-- toJSON = Aeson.String . renderQualifiedHandle
154152

155-
instance FromJSON (Qualified Handle) where
156-
parseJSON = withText "QualifiedHandle" $ either fail pure . mkQualifiedHandle
153+
-- instance FromJSON (Qualified Handle) where
154+
-- parseJSON = withText "QualifiedHandle" $ either fail pure . mkQualifiedHandle
157155

158156
instance FromHttpApiData (Qualified Handle) where
159157
parseUrlPiece = first cs . mkQualifiedHandle

libs/types-common/test/Test/Qualified.hs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,7 @@ testQualifiedSerialization =
6969
\(x :: OptionallyQualified UserId) -> do
7070
let render = Text.E.encodeUtf8 . either (cs . UUID.toString . toUUID) renderQualifiedId . eitherQualifiedOrNot
7171
let parse = BS.C.runParser BS.C.parser
72-
parse (render x) === Right x,
73-
jsonRoundtrip @(Qualified Handle),
74-
jsonRoundtrip @(Qualified UserId)
72+
parse (render x) === Right x
7573
]
7674

7775
jsonRoundtrip ::

libs/wire-api-federation/src/Wire/API/Federation/Event.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
-- This file is part of the Wire Server implementation.
88
--
99
-- Copyright (C) 2020 Wire Swiss GmbH <[email protected]>
10+
1011
--
1112
-- This program is free software: you can redistribute it and/or modify it under
1213
-- the terms of the GNU Affero General Public License as published by the Free
@@ -54,7 +55,7 @@ data AnyEvent
5455
-- To represent possiblity of multiple different event types, use a sum type around it.
5556
data ConversationEvent a = ConversationEvent
5657
{ eventConversation :: Qualified ConvId,
57-
eventFrom :: Qualified UserId,
58+
eventFrom :: UserId,
5859
eventTime :: UTCTime,
5960
eventData :: a
6061
}
@@ -68,7 +69,7 @@ newtype MemberJoin = MemberJoin
6869
deriving (ToJSON, FromJSON) via (CustomEncoded MemberJoin)
6970

7071
data SimpleMember = SimpleMember
71-
{ smId :: Qualified UserId,
72+
{ smId :: UserId,
7273
smConversationRole :: ConversationRole
7374
}
7475
deriving stock (Eq, Show, Generic)

libs/wire-api/package.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ library:
3535
- generic-random >=1.2
3636
- hashable
3737
- hostname-validate
38+
- insert-ordered-containers
3839
- iproute >=1.5
3940
- iso3166-country-codes >=0.2
4041
- iso639 >=0.1

libs/wire-api/src/Wire/API/User.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,15 @@ import qualified Data.Code as Code
111111
import qualified Data.Currency as Currency
112112
import Data.Handle (Handle)
113113
import qualified Data.HashMap.Strict as HashMap
114+
import qualified Data.HashMap.Strict.InsOrd as InsOrdHashMap
114115
import Data.Id
115116
import Data.Json.Util (UTCTimeMillis, (#))
116117
import qualified Data.List as List
117118
import Data.Misc (PlainTextPassword (..))
118119
import Data.Proxy (Proxy (..))
120+
import Data.Qualified (Qualified)
119121
import Data.Range
120-
import Data.Swagger (ToSchema (..), genericDeclareNamedSchema, required, schema)
122+
import Data.Swagger (ToSchema (..), genericDeclareNamedSchema, properties, required, schema)
121123
import qualified Data.Swagger.Build.Api as Doc
122124
import Data.Text.Ascii
123125
import Data.UUID (UUID, nil)
@@ -205,6 +207,7 @@ instance ToSchema UserProfile where
205207
pure $
206208
genericSchema
207209
& over (schema . required) (List.delete "deleted")
210+
& over (schema . properties) (InsOrdHashMap.insert "id" undefined)
208211

209212
modelUser :: Doc.Model
210213
modelUser = Doc.defineModel "User" $ do

libs/wire-api/wire-api.cabal

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ cabal-version: 1.12
44
--
55
-- see: https://github.com/sol/hpack
66
--
7-
-- hash: cb5d5f266e2fdd724d4f01f6136992c85aff49fa7ad01f06f8373a1f3c99abbe
7+
-- hash: 4e9f1f53fb43a39da1366fe060fe0ef8e2b0185847abdc61552ca3262bf25322
88

99
name: wire-api
1010
version: 0.1.0
@@ -97,6 +97,7 @@ library
9797
, hashable
9898
, hostname-validate
9999
, imports
100+
, insert-ordered-containers
100101
, iproute >=1.5
101102
, iso3166-country-codes >=0.2
102103
, iso639 >=0.1

0 commit comments

Comments
 (0)