From 86dad0418899eb37cf5653d2316aad2319c40ea9 Mon Sep 17 00:00:00 2001 From: Lucy <12953208+elvece@users.noreply.github.com> Date: Thu, 11 Jul 2024 17:27:29 -0400 Subject: [PATCH] Fix/insert admin (#144) * change insert to do nothing on conflict * misc protocol updates --- marketplace_protocol.md | 10 ++++++++-- src/Handler/Util.hs | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/marketplace_protocol.md b/marketplace_protocol.md index 468c893..5dcf780 100644 --- a/marketplace_protocol.md +++ b/marketplace_protocol.md @@ -35,7 +35,13 @@ NONE #### Query Params -- (Required) "eos-version-compat": EmverRange specifying what versions of the OS that pack the packages are valid response items +- (Legacy) "eos-version-compat": EmverRange specifying what versions of the OS that pack the packages are valid response items +- (Required) "os.compat": EmverRange specifying what versions of the OS that pack the packages are valid response items +- (Required): "hardware.ram": +- (Required): "hardware.device": +- (Required): "hardware.arch": +- (Required): "os.arch": +- (Legacy): "arch": - (Optional) "ids": json array of package ids - (Optional) "category": string representing - (Optional) "page": which page of the index you want (NOTE: starts at 1) (Default: 1) @@ -63,7 +69,7 @@ NONE // name of dependency "title": "", // icon of dependency - "icon": "" + "icon": "" }, ... } diff --git a/src/Handler/Util.hs b/src/Handler/Util.hs index f293223..e6f632d 100644 --- a/src/Handler/Util.hs +++ b/src/Handler/Util.hs @@ -99,7 +99,7 @@ import Network.HTTP.Types.Status (status401) import Yesod (getsYesod) import Settings (AppSettings(whitelist)) import Network.HTTP.Types (status200) -import Database.Persist (insert_) +import Database.Persist (insert_, insertBy) import Yesod (lookupPostParam) import Data.Maybe (isNothing) @@ -307,7 +307,7 @@ checkAdminAuthUpload pkgId = do else if authorized && newPkg -- if pkg is whitelisted and a new upload, add as authorized for this admin user then do - runDB $ insert_ (AdminPkgs (AdminKey name) pkgId) + _ <- runDB $ insertBy (AdminPkgs (AdminKey name) pkgId) pure name else sendResponseText status401 "User not authorized to upload this package." else sendResponseText status401 "Package does not belong on this registry."