Skip to content

Commit

Permalink
[chore] formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
MangoIV committed Jun 18, 2024
1 parent 9c4d662 commit c243c04
Show file tree
Hide file tree
Showing 801 changed files with 15,697 additions and 13,630 deletions.
22 changes: 11 additions & 11 deletions integration/test/API/Brig.hs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ instance Default UpdateClient where
}

updateClient ::
HasCallStack =>
(HasCallStack) =>
ClientIdentity ->
UpdateClient ->
App Response
Expand Down Expand Up @@ -368,7 +368,7 @@ getSelfWithVersion v user = baseRequest user Brig v "/self" >>= submit "GET"

-- | https://staging-nginz-https.zinfra.io/v6/api/swagger-ui/#/default/get_self
-- this is a low-level version of `getSelf` for testing some error conditions.
getSelf' :: HasCallStack => String -> String -> App Response
getSelf' :: (HasCallStack) => String -> String -> App Response
getSelf' domain uid = getSelfWithVersion Versioned $ object ["domain" .= domain, "id" .= uid]

data PutSelf = PutSelf
Expand Down Expand Up @@ -462,45 +462,45 @@ postInvitation user inv = do
submit "POST" $
req & addJSONObject ["email" .= email]

getApiVersions :: HasCallStack => App Response
getApiVersions :: (HasCallStack) => App Response
getApiVersions = do
req <-
rawBaseRequest OwnDomain Brig Unversioned $
joinHttpPath ["api-version"]
submit "GET" req

getSwaggerPublicTOC :: HasCallStack => App Response
getSwaggerPublicTOC :: (HasCallStack) => App Response
getSwaggerPublicTOC = do
req <-
rawBaseRequest OwnDomain Brig Unversioned $
joinHttpPath ["api", "swagger-ui"]
submit "GET" req

getSwaggerInternalTOC :: HasCallStack => App Response
getSwaggerInternalTOC :: (HasCallStack) => App Response
getSwaggerInternalTOC = error "FUTUREWORK: this API end-point does not exist."

getSwaggerPublicAllUI :: HasCallStack => Int -> App Response
getSwaggerPublicAllUI :: (HasCallStack) => Int -> App Response
getSwaggerPublicAllUI version = do
req <-
rawBaseRequest OwnDomain Brig (ExplicitVersion version) $
joinHttpPath ["api", "swagger-ui"]
submit "GET" req

getSwaggerPublicAllJson :: HasCallStack => Int -> App Response
getSwaggerPublicAllJson :: (HasCallStack) => Int -> App Response
getSwaggerPublicAllJson version = do
req <-
rawBaseRequest OwnDomain Brig (ExplicitVersion version) $
joinHttpPath ["api", "swagger.json"]
submit "GET" req

getSwaggerInternalUI :: HasCallStack => String -> App Response
getSwaggerInternalUI :: (HasCallStack) => String -> App Response
getSwaggerInternalUI service = do
req <-
rawBaseRequest OwnDomain Brig Unversioned $
joinHttpPath ["api-internal", "swagger-ui", service]
submit "GET" req

getSwaggerInternalJson :: HasCallStack => String -> App Response
getSwaggerInternalJson :: (HasCallStack) => String -> App Response
getSwaggerInternalJson service = do
req <-
rawBaseRequest OwnDomain Nginz Unversioned $
Expand Down Expand Up @@ -610,7 +610,7 @@ updateService dom providerId serviceId mAcceptHeader newName = do
$ req

updateServiceConn ::
MakesValue conn =>
(MakesValue conn) =>
-- | providerId
String ->
-- | serviceId
Expand Down Expand Up @@ -662,7 +662,7 @@ getCallsConfigV2 user = do
req <- baseRequest user Brig Versioned $ joinHttpPath ["calls", "config", "v2"]
submit "GET" req

addBot :: MakesValue user => user -> String -> String -> String -> App Response
addBot :: (MakesValue user) => user -> String -> String -> String -> App Response
addBot user providerId serviceId convId = do
req <- baseRequest user Brig Versioned $ joinHttpPath ["conversations", convId, "bots"]
submit "POST" $
Expand Down
3 changes: 2 additions & 1 deletion integration/test/API/BrigInternal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ getClientsFull :: (HasCallStack, MakesValue users, MakesValue uid) => uid -> use
getClientsFull user users = do
val <- make users
baseRequest user Brig Unversioned do joinHttpPath ["i", "clients", "full"]
>>= submit "POST" . addJSONObject ["users" .= val]
>>= submit "POST"
. addJSONObject ["users" .= val]

-- | https://staging-nginz-https.zinfra.io/api-internal/swagger-ui/brig/#/brig/post_i_ejpd_request
getEJPDInfo :: (HasCallStack, MakesValue dom) => dom -> [String] -> String -> App Response
Expand Down
44 changes: 22 additions & 22 deletions integration/test/API/Cargohold.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ getFederationAsset :: (HasCallStack, MakesValue asset) => asset -> App Response
getFederationAsset ga = do
req <- rawBaseRequestF OwnDomain cargohold "federation/get-asset"
bdy <- make ga
submit "POST" $
req
& addBody (HTTP.RequestBodyLBS $ encode bdy) "application/json"
submit "POST"
$ req
& addBody (HTTP.RequestBodyLBS $ encode bdy) "application/json"

uploadAssetV3 :: (HasCallStack, MakesValue user, MakesValue assetRetention) => user -> Bool -> assetRetention -> MIME.MIMEType -> LByteString -> App Response
uploadAssetV3 user isPublic retention mimeType bdy = do
uid <- user & objId
req <- baseRequest user Cargohold (ExplicitVersion 1) "/assets/v3"
body <- buildUploadAssetRequestBody isPublic retention bdy mimeType
submit "POST" $
req
& zUser uid
& addBody body multipartMixedMime
submit "POST"
$ req
& zUser uid
& addBody body multipartMixedMime

uploadAsset :: (HasCallStack, MakesValue user) => user -> App Response
uploadAsset = flip uploadFreshAsset "Hello World!"
Expand All @@ -40,23 +40,23 @@ uploadProviderAsset :: (HasCallStack, MakesValue domain) => domain -> String ->
uploadProviderAsset domain pid payload = do
req <- rawBaseRequest domain Cargohold Versioned $ joinHttpPath ["provider", "assets"]
bdy <- txtAsset payload
submit "POST" $
req
& zProvider pid
& zType "provider"
& addBody bdy multipartMixedMime
submit "POST"
$ req
& zProvider pid
& zType "provider"
& addBody bdy multipartMixedMime

uploadFreshAsset :: (HasCallStack, MakesValue user) => user -> String -> App Response
uploadFreshAsset user payload = do
uid <- user & objId
req <- baseRequest user Cargohold Versioned "/assets"
bdy <- txtAsset payload
submit "POST" $
req
& zUser uid
& addBody bdy multipartMixedMime
submit "POST"
$ req
& zUser uid
& addBody bdy multipartMixedMime

txtAsset :: HasCallStack => String -> App HTTP.RequestBody
txtAsset :: (HasCallStack) => String -> App HTTP.RequestBody
txtAsset payload =
buildUploadAssetRequestBody
True
Expand Down Expand Up @@ -99,7 +99,7 @@ instance {-# OVERLAPS #-} IsAssetLocation String where
locationPathFragment = pure

-- Pick out a path from the value
instance MakesValue loc => IsAssetLocation loc where
instance (MakesValue loc) => IsAssetLocation loc where
locationPathFragment v =
qualifiedFrag `catch` (\(_e :: SomeException) -> unqualifiedFrag)
where
Expand Down Expand Up @@ -137,7 +137,7 @@ downloadAsset user assetDomain key zHostHeader trans = do
domain <- objDomain assetDomain
key' <- asString key
req <- baseRequest user Cargohold Versioned $ "/assets/" ++ domain ++ "/" ++ key'
submit "GET" $
req
& zHost zHostHeader
& trans
submit "GET"
$ req
& zHost zHostHeader
& trans
6 changes: 3 additions & 3 deletions integration/test/API/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ randomClientId = do
mkArray :: [a] -> Array.Array Int a
mkArray l = Array.listArray (0, length l - 1) l

recipient :: MakesValue u => u -> App Value
recipient :: (MakesValue u) => u -> App Value
recipient u = do
uid <- u %. "id"
pure $
object
pure
$ object
[ "user_id" .= uid,
"route" .= "any",
"clients" .= ([] :: [String])
Expand Down
86 changes: 43 additions & 43 deletions integration/test/API/Galley.hs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ allowGuests cc =
instance MakesValue CreateConv where
make cc = do
quids <- for (cc.qualifiedUsers) objQidObject
pure $
Aeson.object $
( [ "qualified_users" .= quids,
pure
$ Aeson.object
$ ( [ "qualified_users" .= quids,
"conversation_role" .= cc.newUsersRole,
"protocol" .= cc.protocol
]
Expand Down Expand Up @@ -158,8 +158,8 @@ getSubConversation ::
getSubConversation user conv sub = do
(cnvDomain, cnvId) <- objQid conv
req <-
baseRequest user Galley Versioned $
joinHttpPath
baseRequest user Galley Versioned
$ joinHttpPath
[ "conversations",
cnvDomain,
cnvId,
Expand All @@ -179,8 +179,8 @@ deleteSubConversation user sub = do
groupId <- sub %. "group_id" & asString
epoch :: Int <- sub %. "epoch" & asIntegral
req <-
baseRequest user Galley Versioned $
joinHttpPath ["conversations", domain, convId, "subconversations", subId]
baseRequest user Galley Versioned
$ joinHttpPath ["conversations", domain, convId, "subconversations", subId]
submit "DELETE" $ req & addJSONObject ["group_id" .= groupId, "epoch" .= epoch]

leaveSubConversation ::
Expand All @@ -192,8 +192,8 @@ leaveSubConversation user sub = do
(conv, Just subId) <- objSubConv sub
(domain, convId) <- objQid conv
req <-
baseRequest user Galley Versioned $
joinHttpPath ["conversations", domain, convId, "subconversations", subId, "self"]
baseRequest user Galley Versioned
$ joinHttpPath ["conversations", domain, convId, "subconversations", subId, "self"]
submit "DELETE" req

getSelfConversation :: (HasCallStack, MakesValue user) => user -> App Response
Expand All @@ -206,34 +206,34 @@ data ListConversationIds = ListConversationIds {pagingState :: Maybe String, siz
instance Default ListConversationIds where
def = ListConversationIds Nothing Nothing

listConversationIds :: MakesValue user => user -> ListConversationIds -> App Response
listConversationIds :: (MakesValue user) => user -> ListConversationIds -> App Response
listConversationIds user args = do
req <- baseRequest user Galley Versioned "/conversations/list-ids"
submit "POST" $
req
& addJSONObject
( ["paging_state" .= s | s <- toList args.pagingState]
<> ["size" .= s | s <- toList args.size]
)
submit "POST"
$ req
& addJSONObject
( ["paging_state" .= s | s <- toList args.pagingState]
<> ["size" .= s | s <- toList args.size]
)

listConversations :: MakesValue user => user -> [Value] -> App Response
listConversations :: (MakesValue user) => user -> [Value] -> App Response
listConversations user cnvs = do
req <- baseRequest user Galley Versioned "/conversations/list"
submit "POST" $
req
& addJSONObject ["qualified_ids" .= cnvs]
submit "POST"
$ req
& addJSONObject ["qualified_ids" .= cnvs]

getMLSPublicKeys :: (HasCallStack, MakesValue user) => user -> App Response
getMLSPublicKeys user = do
req <- baseRequest user Galley Versioned "/mls/public-keys"
submit "GET" req

postMLSMessage :: HasCallStack => ClientIdentity -> ByteString -> App Response
postMLSMessage :: (HasCallStack) => ClientIdentity -> ByteString -> App Response
postMLSMessage cid msg = do
req <- baseRequest cid Galley Versioned "/mls/messages"
submit "POST" (addMLS msg req)

postMLSCommitBundle :: HasCallStack => ClientIdentity -> ByteString -> App Response
postMLSCommitBundle :: (HasCallStack) => ClientIdentity -> ByteString -> App Response
postMLSCommitBundle cid msg = do
req <- baseRequest cid Galley Versioned "/mls/commit-bundles"
submit "POST" (addMLS msg req)
Expand All @@ -253,24 +253,24 @@ mkProteusRecipients :: (HasCallStack, MakesValue domain, MakesValue user, MakesV
mkProteusRecipients dom userClients msg = do
userDomain <- asString =<< objDomain dom
userEntries <- mapM mkUserEntry userClients
pure $
Proto.defMessage
& #domain .~ fromString userDomain
& #entries .~ userEntries
pure
$ Proto.defMessage
& #domain .~ fromString userDomain
& #entries .~ userEntries
where
mkUserEntry (user, clients) = do
userId <- LBS.toStrict . UUID.toByteString . fromJust . UUID.fromString <$> objId user
clientEntries <- mapM mkClientEntry clients
pure $
Proto.defMessage
& #user . #uuid .~ userId
& #clients .~ clientEntries
pure
$ Proto.defMessage
& #user . #uuid .~ userId
& #clients .~ clientEntries
mkClientEntry client = do
clientId <- (^?! hex) <$> objId client
pure $
Proto.defMessage
& #client . #client .~ clientId
& #text .~ fromString msg
pure
$ Proto.defMessage
& #client . #client .~ clientId
& #text .~ fromString msg

getGroupInfo ::
(HasCallStack, MakesValue user, MakesValue conv) =>
Expand Down Expand Up @@ -330,8 +330,8 @@ getMLSOne2OneConversation ::
getMLSOne2OneConversation self other = do
(domain, uid) <- objQid other
req <-
baseRequest self Galley Versioned $
joinHttpPath ["conversations", "one2one", domain, uid]
baseRequest self Galley Versioned
$ joinHttpPath ["conversations", "one2one", domain, uid]
submit "GET" req

getGroupClients ::
Expand Down Expand Up @@ -375,12 +375,12 @@ addMembers usr qcnv opts = do
Galley
(maybe Versioned ExplicitVersion opts.version)
(joinHttpPath path)
submit "POST" $
req
& addJSONObject
( ["qualified_users" .= qUsers]
<> ["conversation_role" .= r | r <- toList opts.role]
)
submit "POST"
$ req
& addJSONObject
( ["qualified_users" .= qUsers]
<> ["conversation_role" .= r | r <- toList opts.role]
)

removeMember :: (HasCallStack, MakesValue remover, MakesValue conv, MakesValue removed) => remover -> conv -> removed -> App Response
removeMember remover qcnv removed = do
Expand Down Expand Up @@ -681,7 +681,7 @@ putLegalholdStatus tid usr status = do

baseRequest usr Galley Versioned (joinHttpPath ["teams", tidStr, "features", "legalhold"])
>>= submit "PUT"
. addJSONObject ["status" .= status, "ttl" .= "unlimited"]
. addJSONObject ["status" .= status, "ttl" .= "unlimited"]

-- | https://staging-nginz-https.zinfra.io/v5/api/swagger-ui/#/default/get_feature_configs
getFeatureConfigs :: (HasCallStack, MakesValue user) => user -> App Response
Expand Down
3 changes: 2 additions & 1 deletion integration/test/API/GalleyInternal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ getFederationStatus user domains =
req <- baseRequest user Galley Unversioned $ joinHttpPath ["i", "federation-status"]
submit
"GET"
$ req & addJSONObject ["domains" .= domainList]
$ req
& addJSONObject ["domains" .= domainList]

-- | https://staging-nginz-https.zinfra.io/api-internal/swagger-ui/galley/#/galley/put_i_legalhold_whitelisted_teams__tid_
legalholdWhitelistTeam :: (HasCallStack, MakesValue uid, MakesValue tid) => tid -> uid -> App Response
Expand Down
Loading

0 comments on commit c243c04

Please sign in to comment.