default to raspberrypi if arch does not exit

This commit is contained in:
Lucy Cifferello
2022-12-19 11:16:27 -05:00
parent 487bb97170
commit 2ba9b71df6

View File

@@ -23,12 +23,14 @@ import Handler.Util (queryParamAs, getArchQuery)
import Lib.Types.Emver (Version, parseVersion)
import Model (EntityField (..), OsVersion (..))
import Orphans.Emver ()
import Startlude (Bool (..), Down (..), Eq, Generic, Maybe (..), Ord ((<)), Show, Text, const, filter, fst, head, maybe, pure, sortOn, ($), (&&&), (.), (<$>), (<&>), (<=), (>>=))
import Startlude (Bool (..), Down (..), Eq, Generic, Maybe (..), Ord ((<)), Show, Text, const, filter, fst, head, maybe, pure, sortOn, ($), (&&&), (.), (<$>), (<&>), (<=))
import Yesod (ToContent (toContent), ToTypedContent (..), YesodPersist (runDB), getsYesod, sendResponseStatus)
import Yesod.Core.Types (JSONResponse (..))
import Settings (AppSettings(maxEosVersion))
import Network.HTTP.Types (status400)
import Lib.Error (S9Error(InvalidParamsE))
import Lib.Types.Core (OsArch(RASPBERRYPI))
import Data.Maybe (fromMaybe)
data EosRes = EosRes
@@ -49,9 +51,7 @@ instance ToTypedContent EosRes where
getEosVersionR :: Handler (JSONResponse (Maybe EosRes))
getEosVersionR = do
currentEosVersion <- queryParamAs "eos-version" parseVersion
getArchQuery >>= \case
Nothing -> sendResponseStatus status400 (InvalidParamsE "Param is required" "arch")
Just arch -> do
arch <- fromMaybe RASPBERRYPI <$> getArchQuery
case currentEosVersion of
Nothing -> sendResponseStatus status400 (InvalidParamsE "Param is required" "eos-version")
Just currentEosVersion' -> do