Skip to content

Commit

Permalink
chore(#1612): fix indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
MSzalowski committed Jul 29, 2024
1 parent 20ba77a commit 6204f1d
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions govtool/backend/src/VVA/Metadata.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,37 +46,37 @@ validateMetadata url hash standard = do
metadataEnabled <- getMetadataValidationEnabled
if not metadataEnabled
then return $ MetadataValidationResult True (Just "Metadata validation disabled") Nothing
else do
metadataHost <- getMetadataValidationHost
metadataPort <- getMetadataValidationPort

let timeout = responseTimeoutMicro 1000
manager <- liftIO $ newManager $ tlsManagerSettings { managerResponseTimeout = timeout }

let requestBody = encode $ object $
["url" .= url, "hash" .= hash] ++ maybe [] (\x -> ["standard" .= x]) standard
requestUrl = unpack metadataHost ++ ":" ++ show metadataPort ++ "/validate"

parsedRequestResult <- liftIO $ try $ parseRequest requestUrl
case parsedRequestResult of
Left (e :: SomeException) -> do
logException url e
return $ MetadataValidationResult False (Just "VALIDATION_FAILED") Nothing
Right initialRequest -> do
let request = initialRequest
{ method = "POST"
, requestBody = RequestBodyLBS requestBody
, requestHeaders = [("Content-Type", "application/json")]
}

responseResult <- liftIO $ try $ httpLbs request manager
case responseResult of
Left (e :: SomeException) -> do
logException url e
return $ MetadataValidationResult False (Just "VALIDATION_FAILED") Nothing
Right response -> case decode (responseBody response) of
Nothing -> return $ MetadataValidationResult False (Just "VALIDATION_FAILED") Nothing
Just x -> return $ MetadataValidationResult True (Just "VALIDATION_SUCCESS") (Just x)
else do
metadataHost <- getMetadataValidationHost
metadataPort <- getMetadataValidationPort

let timeout = responseTimeoutMicro 1000
manager <- liftIO $ newManager $ tlsManagerSettings { managerResponseTimeout = timeout }

let requestBody = encode $ object $
["url" .= url, "hash" .= hash] ++ maybe [] (\x -> ["standard" .= x]) standard
requestUrl = unpack metadataHost ++ ":" ++ show metadataPort ++ "/validate"

parsedRequestResult <- liftIO $ try $ parseRequest requestUrl
case parsedRequestResult of
Left (e :: SomeException) -> do
logException url e
return $ MetadataValidationResult False (Just "VALIDATION_FAILED") Nothing
Right initialRequest -> do
let request = initialRequest
{ method = "POST"
, requestBody = RequestBodyLBS requestBody
, requestHeaders = [("Content-Type", "application/json")]
}

responseResult <- liftIO $ try $ httpLbs request manager
case responseResult of
Left (e :: SomeException) -> do
logException url e
return $ MetadataValidationResult False (Just "VALIDATION_FAILED") Nothing
Right response -> case decode (responseBody response) of
Nothing -> return $ MetadataValidationResult False (Just "VALIDATION_FAILED") Nothing
Just x -> return $ MetadataValidationResult True (Just "VALIDATION_SUCCESS") (Just x)

getProposalMetadataValidationResult ::
(Has ConnectionPool r, Has Manager r, Has VVAConfig r, MonadReader r m, MonadIO m, MonadFail m, MonadError AppError m) =>
Expand Down

0 comments on commit 6204f1d

Please sign in to comment.