Make some basic pack creating endpoints work

This commit is contained in:
Tulir Asokan
2020-11-01 15:21:43 +02:00
parent 0b15a44820
commit 12e1cb265d
9 changed files with 246 additions and 21 deletions

View File

@@ -13,7 +13,8 @@
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from typing import Dict
from typing import Dict, Optional
from collections import deque
import json
from aiohttp import web
@@ -99,6 +100,14 @@ class _ErrorMeta:
return web.HTTPNotFound(**self._make_error("NET.MAUNIUM_PACK_NOT_FOUND",
"Sticker pack not found"))
def schema_error(self, message: str, path: Optional[deque] = None) -> web.HTTPException:
if path:
path_str = "in " + "".join(str(part) for part in path)
else:
path_str = "at top level"
return web.HTTPBadRequest(**self._make_error(
"M_BAD_REQUEST", f"Schema validation error {path_str}: {message}"))
@property
def client_well_known_error(self) -> web.HTTPException:
return web.HTTPForbidden(**self._make_error("NET.MAUNIUM_CLIENT_WELL_KNOWN_ERROR",