Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
23 changes: 15 additions & 8 deletions routers/chats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
)
Expand Down