fix game_code typing

This commit is contained in:
2023-11-05 21:25:38 -05:00
parent dc9879e9b2
commit 59e92268af
10 changed files with 16 additions and 14 deletions

View File

@ -74,11 +74,11 @@ class BaseServlet:
"""
return (False, "")
def render_POST(self, request: Request, game_code: int, matchers: Dict) -> bytes:
def render_POST(self, request: Request, game_code: str, matchers: Dict) -> bytes:
self.logger.warn(f"{game_code} Does not dispatch POST")
return None
def render_GET(self, request: Request, game_code: int, matchers: Dict) -> bytes:
def render_GET(self, request: Request, game_code: str, matchers: Dict) -> bytes:
self.logger.warn(f"{game_code} Does not dispatch GET")
return None

View File

@ -146,7 +146,7 @@ class ChuniServlet(BaseServlet):
return (f"http://{self.core_cfg.title.hostname}/{game_ver}/", "")
def render_POST(self, request: Request, game_code: int, matchers: Dict) -> bytes:
def render_POST(self, request: Request, game_code: str, matchers: Dict) -> bytes:
endpoint = matchers['endpoint']
version = int(matchers['version'])

View File

@ -72,7 +72,7 @@ class CardMakerServlet(BaseServlet):
return True
def render_POST(self, request: Request, game_code: int, matchers: Dict) -> bytes:
def render_POST(self, request: Request, game_code: str, matchers: Dict) -> bytes:
version = int(matchers['version'])
endpoint = matchers['endpoint']
req_raw = request.content.getvalue()

View File

@ -78,7 +78,7 @@ class DivaServlet(BaseServlet):
return True
def render_POST(self, request: Request, game_code: int, matchers: Dict) -> bytes:
def render_POST(self, request: Request, game_code: str, matchers: Dict) -> bytes:
req_raw = request.content.getvalue()
url_header = request.getAllHeaders()

View File

@ -157,7 +157,7 @@ class IDZServlet(BaseServlet):
self.logger.info(f"UserDB Listening on port {self.game_cfg.ports.userdb}")
def render_GET(self, request: Request, game_code: int, matchers: Dict) -> bytes:
def render_GET(self, request: Request, game_code: str, matchers: Dict) -> bytes:
url_path = matchers['endpoint']
self.logger.info(f"IDZ GET request: {url_path}")
request.responseHeaders.setRawHeaders(

View File

@ -155,7 +155,7 @@ class Mai2Servlet(BaseServlet):
f"Failed to make movie upload directory at {self.game_cfg.uploads.movies_dir}"
)
def handle_mai2(self, request: Request, game_code: int, matchers: Dict) -> bytes:
def handle_mai2(self, request: Request, game_code: str, matchers: Dict) -> bytes:
endpoint = matchers['endpoint']
version = int(matchers['version'])
if endpoint.lower() == "ping":

View File

@ -132,7 +132,7 @@ class OngekiServlet(BaseServlet):
f"{self.core_cfg.title.hostname}/",
)
def render_POST(self, request: Request, game_code: int, matchers: Dict) -> bytes:
def render_POST(self, request: Request, game_code: str, matchers: Dict) -> bytes:
endpoint = matchers['endpoint']
version = matchers['version']
if endpoint.lower() == "ping":

View File

@ -108,7 +108,7 @@ class PokkenServlet(BaseServlet):
self.game_cfg.ports.admission, PokkenAdmissionFactory(self.core_cfg, self.game_cfg)
)
def render_POST(self, request: Request, game_code: int, matchers: Dict) -> bytes:
def render_POST(self, request: Request, game_code: str, matchers: Dict) -> bytes:
content = request.content.getvalue()
if content == b"":
self.logger.info("Empty request")
@ -137,7 +137,7 @@ class PokkenServlet(BaseServlet):
ret = handler(pokken_request)
return ret
def handle_matching(self, request: Request, game_code: int, matchers: Dict) -> bytes:
def handle_matching(self, request: Request, game_code: str, matchers: Dict) -> bytes:
if not self.game_cfg.server.enable_matching:
return b""

View File

@ -81,7 +81,7 @@ class SaoServlet(BaseServlet):
return (True, "SAO1")
def render_POST(self, request: Request, game_code: int, matchers: Dict) -> bytes:
def render_POST(self, request: Request, game_code: str, matchers: Dict) -> bytes:
req_url = request.uri.decode()
if req_url == "/matching":
self.logger.info("Matching request")

View File

@ -64,8 +64,10 @@ class WaccaServlet:
def get_endpoint_matchers(self) -> Tuple[List[Tuple[str, str, Dict]], List[Tuple[str, str, Dict]]]:
return (
[],
[("render_POST", "/WaccaServlet/api/{api}/{endpoint}", {}),
("render_POST", "/WaccaServlet/api/{api}/{branch}/{endpoint}", {}),]
[
("render_POST", "/WaccaServlet/api/{api}/{endpoint}", {}),
("render_POST", "/WaccaServlet/api/{api}/{branch}/{endpoint}", {})
]
)
@classmethod
@ -91,7 +93,7 @@ class WaccaServlet:
return (True, f"http://{self.core_cfg.title.hostname}/{game_code}/$v", "")
def render_POST(self, request: Request, game_code: int, matchers: Dict) -> bytes:
def render_POST(self, request: Request, game_code: str, matchers: Dict) -> bytes:
def end(resp: Dict) -> bytes:
hash = md5(json.dumps(resp, ensure_ascii=False).encode()).digest()
request.responseHeaders.addRawHeader(b"X-Wacca-Hash", hash.hex().encode())