diff --git a/agent/src/Handler/Apps.hs b/agent/src/Handler/Apps.hs index b4d0d71aa..54357680d 100644 --- a/agent/src/Handler/Apps.hs +++ b/agent/src/Handler/Apps.hs @@ -210,6 +210,7 @@ getAvailableAppByIdLogic appId = do , appAvailableFullReleaseNotes = storeAppVersionInfoReleaseNotes latest , appAvailableFullDependencyRequirements = HM.elems dependencyRequirements , appAvailableFullVersions = storeAppVersionInfoVersion <$> storeAppVersions + , appAvailableFullInstallWarning = storeAppVersionInfoInstallWarning latest } getAppLogsByIdR :: AppId -> Handler (JSONResponse [Text]) @@ -286,6 +287,7 @@ getInstalledAppByIdLogic appId = do , appInstalledFullLastBackup = backupTime , appInstalledFullTorAddress = Nothing , appInstalledFullConfiguredRequirements = [] + , appInstalledFullUninstallWarning = Nothing } serverApps <- AppMgr2.list [AppMgr2.flags|-s -d|] let remapped = remapAppMgrInfo jobCache serverApps @@ -293,6 +295,7 @@ getInstalledAppByIdLogic appId = do let installed = do (status, version, AppMgr2.InfoRes {..}) <- hoistMaybe (HM.lookup appId remapped) + manifest' <- lift $ LAsync.async $ AppMgr2.infoResManifest <<$>> AppMgr2.info [AppMgr2.flags|-M|] appId instructions' <- lift $ LAsync.async $ AppMgr2.instructions appId requirements <- LAsync.runConcurrently $ flip HML.traverseWithKey @@ -312,16 +315,19 @@ getInstalledAppByIdLogic appId = do (HM.lookup depId installCache $> AppStatusTmp Installing) <|> (view _1 <$> HM.lookup depId remapped) pure $ dependencyInfoToDependencyRequirement (AsInstalled STrue) (base, depStatus, depInfo) + manifest <- lift $ LAsync.wait manifest' instructions <- lift $ LAsync.wait instructions' backupTime <- lift $ LAsync.wait backupTime' - pure AppInstalledFull { appInstalledFullBase = AppBase appId infoResTitle (iconUrl appId version) - , appInstalledFullStatus = status - , appInstalledFullVersionInstalled = version - , appInstalledFullInstructions = instructions - , appInstalledFullLastBackup = backupTime - , appInstalledFullTorAddress = infoResTorAddress - , appInstalledFullConfiguredRequirements = HM.elems requirements - } + pure AppInstalledFull + { appInstalledFullBase = AppBase appId infoResTitle (iconUrl appId version) + , appInstalledFullStatus = status + , appInstalledFullVersionInstalled = version + , appInstalledFullInstructions = instructions + , appInstalledFullLastBackup = backupTime + , appInstalledFullTorAddress = infoResTorAddress + , appInstalledFullConfiguredRequirements = HM.elems requirements + , appInstalledFullUninstallWarning = manifest >>= AppManifest.appManifestUninstallWarning + } runMaybeT (installing <|> installed) `orThrowM` NotFoundE "appId" (show appId) postUninstallAppR :: AppId -> Handler (JSONResponse (WithBreakages ())) @@ -645,6 +651,7 @@ getAvailableAppVersionInfoLogic appId appVersionSpec = do pure AppVersionInfo { appVersionInfoVersion = storeAppVersionInfoVersion , appVersionInfoReleaseNotes = storeAppVersionInfoReleaseNotes , appVersionInfoDependencyRequirements = HM.elems requirements + , appVersionInfoInstallWarning = storeAppVersionInfoInstallWarning } postAutoconfigureR :: AppId -> AppId -> Handler (JSONResponse (WithBreakages AutoconfigureChangesRes)) diff --git a/agent/src/Handler/Types/Apps.hs b/agent/src/Handler/Types/Apps.hs index 867fc05e2..41c60a7d0 100644 --- a/agent/src/Handler/Types/Apps.hs +++ b/agent/src/Handler/Types/Apps.hs @@ -72,6 +72,7 @@ data AppAvailableFull = AppAvailableFull , appAvailableFullDescriptionShort :: Text , appAvailableFullDescriptionLong :: Text , appAvailableFullReleaseNotes :: Text + , appAvailableFullInstallWarning :: Maybe Text , appAvailableFullDependencyRequirements :: [Full AppDependencyRequirement] , appAvailableFullVersions :: NonEmpty Version } @@ -128,6 +129,7 @@ data AppInstalledFull = AppInstalledFull , appInstalledFullInstructions :: Maybe Text , appInstalledFullLastBackup :: Maybe UTCTime , appInstalledFullConfiguredRequirements :: [Stripped AppDependencyRequirement] + , appInstalledFullUninstallWarning :: Maybe Text } instance ToJSON AppInstalledFull where toJSON AppInstalledFull {..} = object @@ -146,6 +148,7 @@ data AppVersionInfo = AppVersionInfo { appVersionInfoVersion :: Version , appVersionInfoReleaseNotes :: Text , appVersionInfoDependencyRequirements :: [Full AppDependencyRequirement] + , appVersionInfoInstallWarning :: Maybe Text } instance ToJSON AppVersionInfo where toJSON AppVersionInfo {..} = object diff --git a/agent/src/Lib/External/AppManifest.hs b/agent/src/Lib/External/AppManifest.hs index 92d124171..38aa07958 100644 --- a/agent/src/Lib/External/AppManifest.hs +++ b/agent/src/Lib/External/AppManifest.hs @@ -48,7 +48,7 @@ instance FromJSON AssetMapping where pure $ AssetMapping { .. } data AppManifest where - AppManifest :: { appManifestId :: AppId + AppManifest ::{ appManifestId :: AppId , appManifestVersion :: Version , appManifestTitle :: Text , appManifestDescShort :: Text @@ -60,6 +60,7 @@ data AppManifest where , appManifestAssets :: [AssetMapping] , appManifestOnionVersion :: OnionVersion , appManifestDependencies :: HM.HashMap AppId VersionRange + , appManifestUninstallWarning :: Maybe Text } -> AppManifest uiAvailable :: AppManifest -> Bool @@ -67,18 +68,19 @@ uiAvailable AppManifest {..} = isJust $ HM.lookup 80 appManifestPortMapping instance FromJSON AppManifest where parseJSON = withObject "App Manifest " $ \o -> do - appManifestId <- o .: "id" - appManifestVersion <- o .: "version" - appManifestTitle <- o .: "title" - appManifestDescShort <- o .: "description" >>= (.: "short") - appManifestDescLong <- o .: "description" >>= (.: "long") - appManifestReleaseNotes <- o .: "release-notes" - appManifestPortMapping <- o .: "ports" >>= fmap HM.fromList . traverse parsePortMapping - appManifestImageType <- o .: "image" >>= (.: "type") - appManifestMount <- o .: "mount" - appManifestAssets <- o .: "assets" >>= traverse parseJSON - appManifestOnionVersion <- o .: "hidden-service-version" - appManifestDependencies <- o .:? "dependencies" .!= HM.empty >>= traverse parseDepInfo + appManifestId <- o .: "id" + appManifestVersion <- o .: "version" + appManifestTitle <- o .: "title" + appManifestDescShort <- o .: "description" >>= (.: "short") + appManifestDescLong <- o .: "description" >>= (.: "long") + appManifestReleaseNotes <- o .: "release-notes" + appManifestPortMapping <- o .: "ports" >>= fmap HM.fromList . traverse parsePortMapping + appManifestImageType <- o .: "image" >>= (.: "type") + appManifestMount <- o .: "mount" + appManifestAssets <- o .: "assets" >>= traverse parseJSON + appManifestOnionVersion <- o .: "hidden-service-version" + appManifestDependencies <- o .:? "dependencies" .!= HM.empty >>= traverse parseDepInfo + appManifestUninstallWarning <- o .:? "uninstall-warning" pure $ AppManifest { .. } where parsePortMapping = withObject "Port Mapping" $ \o -> liftA2 (,) (o .: "tor") (o .: "internal") diff --git a/agent/src/Lib/Types/ServerApp.hs b/agent/src/Lib/Types/ServerApp.hs index 61dccc34c..34892a01c 100644 --- a/agent/src/Lib/Types/ServerApp.hs +++ b/agent/src/Lib/Types/ServerApp.hs @@ -24,16 +24,18 @@ data StoreApp = StoreApp deriving (Eq, Show) data StoreAppVersionInfo = StoreAppVersionInfo - { storeAppVersionInfoVersion :: Version - , storeAppVersionInfoReleaseNotes :: Text + { storeAppVersionInfoVersion :: Version + , storeAppVersionInfoReleaseNotes :: Text + , storeAppVersionInfoInstallWarning :: Maybe Text } deriving (Eq, Show) instance Ord StoreAppVersionInfo where compare = compare `on` storeAppVersionInfoVersion instance FromJSON StoreAppVersionInfo where parseJSON = withObject "Store App Version Info" $ \o -> do - storeAppVersionInfoVersion <- o .: "version" - storeAppVersionInfoReleaseNotes <- o .: "release-notes" + storeAppVersionInfoVersion <- o .: "version" + storeAppVersionInfoReleaseNotes <- o .: "release-notes" + storeAppVersionInfoInstallWarning <- o .: "install-warning" pure StoreAppVersionInfo { .. } instance ToJSON StoreAppVersionInfo where toJSON StoreAppVersionInfo {..} =