From db8a26c84c121837cc2b183167c5c55badbe43b4 Mon Sep 17 00:00:00 2001 From: Aaron Greenspan Date: Tue, 19 Jan 2021 18:29:29 -0700 Subject: [PATCH] agent: adds restore alerts --- agent/src/Handler/Apps.hs | 4 +++- agent/src/Handler/Types/Apps.hs | 2 ++ agent/src/Lib/External/AppManifest.hs | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/agent/src/Handler/Apps.hs b/agent/src/Handler/Apps.hs index 563dac58f..261a7d771 100644 --- a/agent/src/Handler/Apps.hs +++ b/agent/src/Handler/Apps.hs @@ -288,6 +288,7 @@ getInstalledAppByIdLogic appId = do , appInstalledFullTorAddress = Nothing , appInstalledFullConfiguredRequirements = [] , appInstalledFullUninstallAlert = Nothing + , appInstalledFullRestoreAlert = Nothing } serverApps <- AppMgr2.list [AppMgr2.flags|-s -d|] let remapped = remapAppMgrInfo jobCache serverApps @@ -325,7 +326,8 @@ getInstalledAppByIdLogic appId = do , appInstalledFullLastBackup = backupTime , appInstalledFullTorAddress = infoResTorAddress , appInstalledFullConfiguredRequirements = HM.elems requirements - , appInstalledFullUninstallAlert = manifest >>= AppManifest.appManifestUninstallAlert + , appInstalledFullUninstallAlert = manifest >>= AppManifest.appManifestUninstallAlert + , appInstalledFullRestoreAlert = manifest >>= AppManifest.appManifestRestoreAlert } runMaybeT (installing <|> installed) `orThrowM` NotFoundE "appId" (show appId) diff --git a/agent/src/Handler/Types/Apps.hs b/agent/src/Handler/Types/Apps.hs index 15ec0dd51..0850d3e96 100644 --- a/agent/src/Handler/Types/Apps.hs +++ b/agent/src/Handler/Types/Apps.hs @@ -132,6 +132,7 @@ data AppInstalledFull = AppInstalledFull , appInstalledFullLastBackup :: Maybe UTCTime , appInstalledFullConfiguredRequirements :: [Stripped AppDependencyRequirement] , appInstalledFullUninstallAlert :: Maybe Text + , appInstalledFullRestoreAlert :: Maybe Text } instance ToJSON AppInstalledFull where toJSON AppInstalledFull {..} = object @@ -145,6 +146,7 @@ instance ToJSON AppInstalledFull where , "versionInstalled" .= appInstalledFullVersionInstalled , "status" .= appInstalledFullStatus , "uninstallAlert" .= appInstalledFullUninstallAlert + , "restoreAlert" .= appInstalledFullRestoreAlert ] data AppVersionInfo = AppVersionInfo diff --git a/agent/src/Lib/External/AppManifest.hs b/agent/src/Lib/External/AppManifest.hs index 7e216e3e5..4d85c2c77 100644 --- a/agent/src/Lib/External/AppManifest.hs +++ b/agent/src/Lib/External/AppManifest.hs @@ -61,6 +61,7 @@ data AppManifest where , appManifestOnionVersion :: OnionVersion , appManifestDependencies :: HM.HashMap AppId VersionRange , appManifestUninstallAlert :: Maybe Text + , appManifestRestoreAlert :: Maybe Text } -> AppManifest uiAvailable :: AppManifest -> Bool @@ -81,6 +82,7 @@ instance FromJSON AppManifest where appManifestOnionVersion <- o .: "hidden-service-version" appManifestDependencies <- o .:? "dependencies" .!= HM.empty >>= traverse parseDepInfo appManifestUninstallAlert <- o .:? "uninstall-alert" + appManifestRestoreAlert <- o .:? "restore-alert" pure $ AppManifest { .. } where parsePortMapping = withObject "Port Mapping" $ \o -> liftA2 (,) (o .: "tor") (o .: "internal")