Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -80,6 +80,7 @@ async def get_customized_avatar(
|
||||
clothe_color=clothe_color,
|
||||
clothe_graphic_type=clothe_graphic_type,
|
||||
).render_svg()
|
||||
# skipcq: PY-W0069
|
||||
# print(f"skin_color: {len(AvatarItemsAsList.skin_color)},")
|
||||
# print(f"hair_color: {len(AvatarItemsAsList.hair_color)},")
|
||||
# print(f"facial_hair_type: {len(AvatarItemsAsList.facial_hair_type)},")
|
||||
|
||||
@@ -109,7 +109,7 @@ button_to_index_map = {"b": 0, "g": 1, "y": 2, "r": 3}
|
||||
@router.websocket("/socket/{id}")
|
||||
async def websocket_endpoint(ws: WebSocket, game_id: str, id: str):
|
||||
try:
|
||||
if id in wss_clients.keys():
|
||||
if id in wss_clients:
|
||||
await ws.close(code=status.WS_1001_GOING_AWAY)
|
||||
print("Client {} already exists.".format(id))
|
||||
return
|
||||
|
||||
@@ -26,7 +26,7 @@ def generate_code() -> str:
|
||||
"r",
|
||||
] # Capital stands for long press, lowercase letter for short press
|
||||
resulting_code = ""
|
||||
for i in range(specified_length):
|
||||
for _ in range(specified_length):
|
||||
resulting_code += random.choice(buttons)
|
||||
return resulting_code
|
||||
|
||||
|
||||
@@ -106,9 +106,6 @@ async def finish_edit(edit_id: str, quiz_input: QuizInput):
|
||||
if quiz_input.cover_image == "":
|
||||
quiz_input.cover_image = None
|
||||
|
||||
# if quiz_input.background_image is None and old_quiz_data.background_image is not None:
|
||||
# mark_image_for_deletion(quiz_input.background_image)
|
||||
|
||||
if quiz_input.cover_image is not None and not check_image_string(quiz_input.cover_image)[0]:
|
||||
raise HTTPException(status_code=400, detail="image url is not valid")
|
||||
|
||||
|
||||
@@ -46,9 +46,8 @@ async def export_quiz(quiz_id: uuid.UUID, user: User = Depends(get_current_user)
|
||||
quiz_dict["updated_at"] = quiz_dict["updated_at"].isoformat()
|
||||
quiz_json = json.dumps(quiz_dict)
|
||||
bin_data = gzip.compress(quiz_json.encode("utf-8"), compresslevel=9)
|
||||
# bin_data = quiz_json.encode("utf-8")
|
||||
bin_data = bin_data + quiz_delimiter
|
||||
for image_key in image_urls.keys():
|
||||
for image_key in image_urls:
|
||||
bin_data = bin_data + image_delimiter + str(image_key).encode("utf-8") + image_index_delimiter
|
||||
image_data = None
|
||||
async with ClientSession() as session, session.get(
|
||||
|
||||
@@ -134,8 +134,6 @@ async def get_live_game_data(
|
||||
|
||||
@router.get("/user_count")
|
||||
async def get_game_user_count(game_pin: str, api_key: str, as_string: bool = False, as_array: bool = False):
|
||||
# if redis_res is None:
|
||||
# raise HTTPException(status_code=404, detail="Game not found")
|
||||
user_id = await check_api_key(api_key)
|
||||
redis_res = await redis.get(f"game_session:{game_pin}")
|
||||
if redis_res is None:
|
||||
@@ -149,12 +147,6 @@ async def get_game_user_count(game_pin: str, api_key: str, as_string: bool = Fal
|
||||
return {"players": {"count": player_count}}
|
||||
|
||||
|
||||
# class _LivePlayersReturn(BaseModel):
|
||||
# # players: list[GamePlayer | None]
|
||||
# answers: list[GameAnswer1 | None]
|
||||
# players: list[GamePlayer | None]
|
||||
|
||||
|
||||
@router.get(
|
||||
"/players",
|
||||
)
|
||||
|
||||
@@ -149,7 +149,7 @@ class StepInput(BaseModel):
|
||||
|
||||
|
||||
@router.post("/step/{step_id}")
|
||||
async def step_1(session_id: str, data: StepInput, request: Request, response: Response, step_id: int):
|
||||
async def step_1_endpoint(session_id: str, data: StepInput, request: Request, response: Response, step_id: int):
|
||||
if step_id < 0 or step_id > 2:
|
||||
raise HTTPException(status_code=401)
|
||||
redis_res = await redis.get(f"login_session:{session_id}")
|
||||
|
||||
@@ -83,7 +83,7 @@ def generate_code() -> str:
|
||||
"r",
|
||||
] # Capital stands for long press, lowercase letter for short press
|
||||
resulting_code = ""
|
||||
for i in range(specified_length):
|
||||
for _ in range(specified_length):
|
||||
resulting_code += random.choice(buttons)
|
||||
return resulting_code
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ async def set_note(id: UUID, data: _SetNoteInput, user: User = Depends(get_curre
|
||||
return await res.update()
|
||||
|
||||
|
||||
# skipcq: PYL-W0105
|
||||
"""
|
||||
@router.get("/export/{result_id}", response_class=StreamingResponse)
|
||||
async def export_result(result_id: UUID, user: User = Depends(get_current_user)):
|
||||
|
||||
@@ -197,6 +197,10 @@ async def update_image_data(
|
||||
file_data = await StorageItem.objects.get_or_none(id=file_id, user=user, deleted_at=None)
|
||||
if file_data is None:
|
||||
raise HTTPException(status_code=404, detail="File not found")
|
||||
if data.alt_text == "":
|
||||
data.alt_text = None
|
||||
if data.filename == "":
|
||||
data.filename = None
|
||||
file_data.filename = data.filename
|
||||
file_data.alt_text = data.alt_text
|
||||
await file_data.update()
|
||||
@@ -221,7 +225,6 @@ async def list_images(
|
||||
raise HTTPException(status_code=404, detail="No items found")
|
||||
return_items: list[PrivateStorageItem] = []
|
||||
for item in storage_items:
|
||||
# print(item.quizzes)
|
||||
return_items.append(PrivateStorageItem.from_db_model(item))
|
||||
return return_items
|
||||
|
||||
|
||||
@@ -79,7 +79,6 @@ async def create_user(user: RouteUser, background_task: BackgroundTasks) -> User
|
||||
if len(user.username) == 32:
|
||||
return JSONResponse({"details": "Username mustn't be 32 characters long"}, 400)
|
||||
await user.save()
|
||||
# print(settings.skip_email_verification)
|
||||
if settings.skip_email_verification:
|
||||
user.verify_key = None
|
||||
user.verified = True
|
||||
|
||||
Reference in New Issue
Block a user