fix: process list patch values in http requests

This commit parses values from post request as well as always serializes
values for the web interface
This commit is contained in:
2024-11-22 17:22:37 +02:00
parent 3c1fdec0e9
commit 45a620c40b
7 changed files with 29 additions and 6 deletions

View File

@@ -101,6 +101,6 @@ class PatchesView(StatusViewGuard, BaseView):
except Exception as ex:
raise HTTPBadRequest(reason=str(ex))
self.service().package_patches_update(package_base, PkgbuildPatch(key, value))
self.service().package_patches_update(package_base, PkgbuildPatch.parse(key, value))
raise HTTPNoContent

View File

@@ -68,7 +68,7 @@ class AddView(BaseView):
try:
data = await self.request.json()
packages = self.get_non_empty(lambda key: [package for package in data[key] if package], "packages")
patches = [PkgbuildPatch(patch["key"], patch.get("value", "")) for patch in data.get("patches", [])]
patches = [PkgbuildPatch.parse(patch["key"], patch.get("value", "")) for patch in data.get("patches", [])]
except Exception as ex:
raise HTTPBadRequest(reason=str(ex))

View File

@@ -68,7 +68,7 @@ class RequestView(BaseView):
try:
data = await self.request.json()
packages = self.get_non_empty(lambda key: [package for package in data[key] if package], "packages")
patches = [PkgbuildPatch(patch["key"], patch.get("value", "")) for patch in data.get("patches", [])]
patches = [PkgbuildPatch.parse(patch["key"], patch.get("value", "")) for patch in data.get("patches", [])]
except Exception as ex:
raise HTTPBadRequest(reason=str(ex))