From 6e9288a7af81f64556a0707106cc4ede418bcce6 Mon Sep 17 00:00:00 2001 From: Lucy Cifferello <12953208+elvece@users.noreply.github.com> Date: Fri, 16 Jul 2021 13:36:37 -0400 Subject: [PATCH] fix instruction and license parsing --- src/Handler/Marketplace.hs | 15 +++------------ src/Util/Shared.hs | 2 -- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/Handler/Marketplace.hs b/src/Handler/Marketplace.hs index 824588f..6198fd3 100644 --- a/src/Handler/Marketplace.hs +++ b/src/Handler/Marketplace.hs @@ -49,7 +49,7 @@ data ServiceRes = ServiceRes { serviceResIcon :: Text , serviceResManifest :: ServiceManifest , serviceResCategories :: [CategoryTitle] - , serviceResInstructions :: Text -- markdown + , serviceResInstructions :: Text , serviceResLicense :: Text , serviceResVersions :: [Version] , serviceResDependencyInfo :: HM.HashMap AppIdentifier DependencyInfo @@ -307,7 +307,6 @@ getServiceDetails maybeVersion service = do sendResponseStatus status500 ("Internal Server Error" :: Text) Right (a :: ServiceManifest) -> pure a d <- traverse (mapDependencyMetadata appsDir appMgrDir domain) (HM.toList $ serviceManifestDependencies manifest) - $logInfo $ show appDir -- @TODO uncomment when sdk icon working -- icon <- decodeIcon appMgrDir appDir appExt let icon = [i|https://#{domain}/icons/#{appId}.png|] @@ -352,20 +351,12 @@ decodeIcon appmgrPath depPath e@(Extension icon) = do decodeInstructions :: (MonadHandler m, KnownSymbol a) => FilePath -> FilePath -> Extension a -> m Text decodeInstructions appmgrPath depPath package = do instructions <- handleS9ErrT $ getInstructions appmgrPath depPath package - case eitherDecode $ BS.fromStrict instructions of - Left e -> do - $logInfo $ T.pack e - sendResponseStatus status400 e - Right a -> pure a + pure $ decodeUtf8 instructions decodeLicense :: (MonadHandler m, KnownSymbol a) => FilePath -> FilePath -> Extension a -> m Text decodeLicense appmgrPath depPath package = do license <- handleS9ErrT $ getLicense appmgrPath depPath package - case eitherDecode $ BS.fromStrict license of - Left e -> do - $logInfo $ T.pack e - sendResponseStatus status400 e - Right a -> pure a + pure $ decodeUtf8 license fetchAllAppVersions :: Key SApp -> HandlerFor RegistryCtx ([VersionInfo], ReleaseNotes) fetchAllAppVersions appId = do diff --git a/src/Util/Shared.hs b/src/Util/Shared.hs index ec568e2..bc9fde3 100644 --- a/src/Util/Shared.hs +++ b/src/Util/Shared.hs @@ -29,8 +29,6 @@ getBestVersion rootDir ext spec = do appVersions <- liftIO $ getAvailableAppVersions rootDir ext let satisfactory = filter ((<|| spec) . fst . unRegisteredAppVersion) appVersions let best = getMax <$> foldMap (Just . Max . fst . unRegisteredAppVersion) satisfactory - $logInfo $ show satisfactory - $logInfo $ show best pure best addPackageHeader :: (MonadHandler m, KnownSymbol a) => FilePath -> FilePath -> Extension a -> m ()