Skip to content

Dev/2.3.1#68

Merged
ink-developer merged 5 commits into
mainfrom
dev/2.3.1
Jun 19, 2026
Merged

Dev/2.3.1#68
ink-developer merged 5 commits into
mainfrom
dev/2.3.1

Conversation

@ink-developer

@ink-developer ink-developer commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Описание

Подготавливает PyMax 2.3.1: добавляет пересылку сообщений, исправляет декодирование сжатых TCP payload-ов и разбор профилей bot-аккаунтов. Обновляет документацию, patch notes и версию пакета.

Тип изменений

  • Исправление бага
  • Новая функциональность
  • Улучшение документации
  • Рефакторинг

Связанные задачи / Issue

#66
#67

Summary by CodeRabbit

  • New Features

    • Added message forwarding functionality to send messages between chats.
  • Bug Fixes

    • Resolved message payload decompression errors in network communication.
    • Improved bot profile field parsing and compatibility.
  • Dependencies

    • Added new decompression library dependency.
  • Documentation

    • Updated with release notes and forwarding usage examples.

MikeMike88 and others added 5 commits June 19, 2026 13:41
MAX bots send `gender` as a numeric code and `web_app` as a URL string
instead of an object, so `User.model_validate` raised a ValidationError
and the bot user failed to load. Widen both field types
(gender: str | int, web_app: dict | str) and add regression tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

PyMax 2.3.1 adds a message forwarding API (forward_message() on the service/mixin and Message.forward() on the bound model), fixes TCP payload decompression to support Zstandard (flag 0xFF) alongside LZ4 with strict flag dispatch, widens User field types to accept bot-provided numeric gender and URL web_app, and bumps the version with matching docs and the zstandard runtime dependency.

Changes

PyMax 2.3.1 Release

Layer / File(s) Summary
Forward message payload schemas and service method
src/pymax/api/messages/payloads.py, src/pymax/api/messages/service.py, tests/api/test_message_service.py
ForwardLink, ForwardMessagePayloadMessage, and ForwardMessagePayload Pydantic schemas are added with a Literal["FORWARD"] discriminator. MessageService.forward_message builds and sends the payload via Opcode.MSG_SEND, returning the forwarded Message. Tests verify payload shape, negative cid, and source_chat_id defaulting.
Message.forward bound method and client MessageMixin
src/pymax/types/domain/message.py, src/pymax/infra/message.py, tests/domain/test_bound_models.py
Message.forward resolves source_chat_id via _bound() and delegates to the service. MessageMixin.forward_message exposes forwarding at the client level. Bound-model tests assert delegation and return value.
ZstdCompression and TcpPayloadDecoder flag dispatch
src/pymax/protocol/tcp/compression.py, src/pymax/protocol/tcp/payload.py, src/pymax/protocol/tcp/protocol.py, tests/protocol/test_protocols.py
ZstdCompression.decompress is added with size-limit enforcement and ZstdError translation. TcpPayloadDecoder.decode replaces bitmask LZ4 logic with explicit flag checks: 0xFF→Zstd, >0x7F→invalid, >0→LZ4. TcpProtocol instantiates and wires ZstdCompression. Tests cover LZ4, Zstd, and oversize rejection.
User model bot profile field type widening
src/pymax/types/domain/user.py, tests/domain/test_user_models.py
User.gender widens to str | int | None and User.web_app to dict[str, Any] | str | None. Three new tests validate numeric gender, absent optional fields, and dict web_app backward compatibility.
Version bump, zstandard dependency, and docs
pyproject.toml, src/pymax/__init__.py, docs/release-2-3-1.rst, docs/index.rst, docs/client.rst, docs/messages.rst
Version bumped to 2.3.1, zstandard>=0.25.0 added as a dependency, release notes document all changes, and the messages doc is extended with forwarding examples.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • MaxApiTeam/PyMax#66: Directly related — addresses the same User model bot profile parsing issue for gender and web_app field types that this PR also fixes and tests.

Poem

🐇 Hop hop, a message flies across the chat,
forward_message() handles this and that.
Zstandard joins LZ4 in the decode lane,
A bot's numeric gender? No longer in vain.
Version two-three-one is tagged and neat —
The rabbit stamps the docs: release complete! 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (1 warning, 2 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Dev/2.3.1' is vague and does not clearly convey the main changes; it only indicates a version bump without describing what functionality or fixes are included. Use a descriptive title that summarizes the primary changes, such as 'Add message forwarding and fix TCP payload decompression' or 'Release PyMax 2.3.1: message forwarding, TCP fixes, and bot profile parsing'.
Description check ❓ Inconclusive The description addresses all required template sections: a concise summary of changes, type selection (bug fix, new feature, documentation), and linked issues; however, the testing section is completely empty. Add a code example in the testing section demonstrating the new message forwarding functionality or other key changes introduced in this release.
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev/2.3.1

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/messages.rst (1)

69-74: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Guard the message.forward() example when chat_id is missing.

Message.forward() depends on a source chat from the bound message; in partial events this can be absent, causing a runtime failure in copied examples.

Suggested doc fix
   `@client.on_message`()
   async def on_message(message: Message, client: Client) -> None:
       await message.answer("Ответ в тот же чат")
       await message.reply("Ответ реплаем")
-      await message.forward(chat_id=654321)
+      if message.chat_id is not None:
+          await message.forward(chat_id=654321)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/messages.rst` around lines 69 - 74, The `message.forward()` call in the
on_message handler example lacks protection for cases where the message lacks a
source chat context (in partial events), which would cause a runtime failure.
Add a conditional guard before the `message.forward(chat_id=654321)` invocation
to verify that the message has a valid source chat context available, and only
proceed with the forward operation when this context is present, ensuring the
example is safe for all event scenarios.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@docs/messages.rst`:
- Around line 69-74: The `message.forward()` call in the on_message handler
example lacks protection for cases where the message lacks a source chat context
(in partial events), which would cause a runtime failure. Add a conditional
guard before the `message.forward(chat_id=654321)` invocation to verify that the
message has a valid source chat context available, and only proceed with the
forward operation when this context is present, ensuring the example is safe for
all event scenarios.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 66b64c84-1da5-4a67-9416-2f4052fee9f7

📥 Commits

Reviewing files that changed from the base of the PR and between ff3af5b and c712108.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (18)
  • docs/client.rst
  • docs/index.rst
  • docs/messages.rst
  • docs/release-2-3-1.rst
  • pyproject.toml
  • src/pymax/__init__.py
  • src/pymax/api/messages/payloads.py
  • src/pymax/api/messages/service.py
  • src/pymax/infra/message.py
  • src/pymax/protocol/tcp/compression.py
  • src/pymax/protocol/tcp/payload.py
  • src/pymax/protocol/tcp/protocol.py
  • src/pymax/types/domain/message.py
  • src/pymax/types/domain/user.py
  • tests/api/test_message_service.py
  • tests/domain/test_bound_models.py
  • tests/domain/test_user_models.py
  • tests/protocol/test_protocols.py

@ink-developer ink-developer merged commit 8c40b71 into main Jun 19, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants