From b91aa352f5d2be2360a2d42727db785d6e7184d3 Mon Sep 17 00:00:00 2001 From: Sagar Date: Sat, 15 Aug 2026 22:02:34 +0530 Subject: [PATCH] Accept call-state chat message types for live voice/video signalling. Allow REST message types 52-60 through send_message validation so decline/cancel/no-answer flows work alongside the websocket call handlers. --- Dockerfile | 2 ++ routers/chats.py | 23 +++++++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 46fc375..7457bc4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,8 @@ ENV PYTHONUNBUFFERED=1 \ RUN useradd -U -u 1000 -m appuser && \ mkdir -p /home/appuser/.cache/uv && \ + apt-get update && apt-get install -y --no-install-recommends ca-certificates && \ + rm -rf /var/lib/apt/lists/* && \ chown -R 1000:1000 /app /home/appuser/ COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ diff --git a/routers/chats.py b/routers/chats.py index 01599fc..c9acf04 100644 --- a/routers/chats.py +++ b/routers/chats.py @@ -925,6 +925,8 @@ async def get_chat_messages( # send message # /g/s/chat/thread/434cd5b4-a984-42c4-8375-46c1c6e0803d/message +CALL_STATE_MESSAGE_TYPES = list(range(52, 61)) + @chats.post("/g/s/chat/thread/{chatId}/message") @chats.post("/x{ndcId}/s/chat/thread/{chatId}/message") @@ -936,34 +938,39 @@ async def send_message(request: Request, chatId: str, ndcId: int = 0): try: data = await request.json() + allowed_types = [0, 2, 3] + CALL_STATE_MESSAGE_TYPES + is_call_state = data["type"] in CALL_STATE_MESSAGE_TYPES if ( ( - # [info] types in messagetypes.json - data["type"] not in [0, 2, 3] + data["type"] not in allowed_types ) or ( - data.get("mediaType") + not is_call_state + and data.get("mediaType") and data["mediaType"] != 113 and (not data.get("mediaUploadValue")) ) or ( - data.get("mediaType", 0) == 103 + not is_call_state + and data.get("mediaType", 0) == 103 and ( not data.get("mediaUploadValue", "").startswith("ytv://") or data["type"] != 0 ) ) - or (data.get("mediaType", 0) == 110 and data["type"] != 2) - or (data["type"] != 0 and data.get("content") is not None) + or (not is_call_state and data.get("mediaType", 0) == 110 and data["type"] != 2) + or (not is_call_state and data["type"] != 0 and data.get("content") is not None) or ( - data["type"] == 3 + not is_call_state + and data["type"] == 3 and ( not isinstance(data.get("stickerId"), str) or not data["stickerId"].startswith("e/") ) ) or ( - data["type"] == 0 + not is_call_state + and data["type"] == 0 and data.get("mediaType", 0) == 0 and not isinstance(data.get("content"), str) )