From f74966002ef9357ca2570665781a19fa47b7766e Mon Sep 17 00:00:00 2001 From: Keeboy Date: Tue, 9 Jun 2026 07:46:43 +0000 Subject: [PATCH] chimedb update to match SDGB 1.55 uhhh hopefully doesnt break older versions --- core/chimedb.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/core/chimedb.py b/core/chimedb.py index 6e87f69..a2e29f7 100644 --- a/core/chimedb.py +++ b/core/chimedb.py @@ -1,6 +1,8 @@ import hashlib import json import logging +import secrets +import string from enum import Enum from logging.handlers import TimedRotatingFileHandler @@ -69,10 +71,15 @@ class ChimeServlet: async def handle_qr_alive(self, request: Request): return PlainTextResponse("alive") + def _generate_token(self) -> str: + alphabet = string.ascii_letters + string.digits + return ''.join(secrets.choice(alphabet) for _ in range(20)) + async def handle_qr_lookup(self, request: Request) -> bytes: req = json.loads(await request.body()) access_code = req["qrCode"][-20:] timestamp = req["timestamp"] + token = self._generate_token() try: userId = await self._lookup(access_code) @@ -80,7 +87,8 @@ class ChimeServlet: "userID": userId, "errorID": 0, "timestamp": timestamp, - "key": self._hash_key(userId, timestamp) + "key": self._hash_key(userId, timestamp), + "token": token }) except Exception as e: @@ -90,7 +98,8 @@ class ChimeServlet: "userID": -1, "errorID": ChimeDBStatus.DB_ACCESS_FAIL, "timestamp": timestamp, - "key": self._hash_key(-1, timestamp) + "key": self._hash_key(-1, timestamp), + "token": token }) return PlainTextResponse(data)