Skip to content

Commit

Permalink
chore: remove basically unused schema package
Browse files Browse the repository at this point in the history
  • Loading branch information
mikonse committed Nov 5, 2023
1 parent 7c49463 commit 02b61eb
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 49 deletions.
1 change: 0 additions & 1 deletion abrechnung/application/transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ async def _add_file_to_revision(
async def _update_file_in_revision(
*, conn: Connection, revision_id: int, transaction_id: int, attachment: UpdateFile
) -> int:

if "." in attachment.filename:
raise InvalidCommand(f"Dots '.' are not allowed in file names")

Expand Down
49 changes: 1 addition & 48 deletions abrechnung/http/routers/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from typing import Optional

import asyncpg
import schema
from fastapi import APIRouter, Request, WebSocket, WebSocketException, status

from abrechnung.application.users import UserService
Expand All @@ -17,48 +16,6 @@
tags=["websocket"],
)

CLIENT_SCHEMA = schema.Schema(
schema.Or(
{
"type": "subscribe",
"token": str,
"data": {"subscription_type": str, "element_id": int},
},
{
"type": "unsubscribe",
"token": str,
"data": {"subscription_type": str, "element_id": int},
},
)
)

SERVER_SCHEMA = schema.Schema(
schema.Or(
{"type": "error", "data": {"code": int, "msg": str}},
{
"type": "notification",
"data": {
"subscription_type": str,
"element_id": int,
},
},
{
"type": "subscribe_success",
"data": {
"subscription_type": str,
"element_id": int,
},
},
{
"type": "unsubscribe_success",
"data": {
"subscription_type": str,
"element_id": int,
},
},
)
)


def make_error_msg(code: int, msg: str) -> dict:
return {"type": "error", "data": {"code": code, "msg": msg}}
Expand Down Expand Up @@ -202,14 +159,10 @@ async def websocket_endpoint(
try:
while True:
msg = await ws.receive_json()
CLIENT_SCHEMA.validate(msg)
try:
async with db_pool.acquire() as connection:
response = await ws_message(connection, connection_id, msg, user_service)
except (
asyncpg.DataError,
schema.SchemaError,
) as exc:
except asyncpg.DataError as exc:
response = make_error_msg(code=status.HTTP_400_BAD_REQUEST, msg=str(exc))
except Exception as exc:
traceback.print_exc()
Expand Down

0 comments on commit 02b61eb

Please sign in to comment.