Merge pull request 'chimedb update to match SDGB 1.55' (#246) from Keeboy/artemis:develop into develop

Reviewed-on: https://gitea.tendokyu.moe/Hay1tsme/artemis/pulls/246
This commit is contained in:
Hay1tsme
2026-08-01 05:24:49 +00:00

View File

@@ -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)