Skip to content

feat: sync with Bot API schema 0.0.33 - #44

Merged
BushlanovDev merged 10 commits into
BushlanovDev:masterfrom
smotim:sync/api-schema-0.0.33
Oct 1, 2026
Merged

BushlanovDev merged 10 commits into
BushlanovDev:masterfrom
smotim:sync/api-schema-0.0.33

Conversation

@smotim

@smotim smotim commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Сверил библиотеку с официальной OpenAPI-схемой MAX — max-messenger/api-schema, версия 0.0.33 от 17.09.2026, — и с changelog API. Копия схемы в docs/ была версии 0.0.6, заменил её на официальную.

Ветка основана на #43 (editBotCommands): пока он не влит, его коммит виден и здесь.

Исправления

  • lastActivityTime может отсутствовать. В 0.0.33 User.last_activity_time необязательный. Сейчас пользователь без него падает с TypeError: Argument #6 ($lastActivityTime) must be of type int, null given, а вместе с ним теряется всё событие. AbstractUser::$lastActivityTime стал ?int.
  • События comment_created, comment_edited, comment_removed, bot_admin_permissions_changed. Они уже были в UpdateType, но ModelFactory::createUpdate() бросал на них «Unknown or unsupported update type». Добавил модели, маппинг и on*() в UpdateDispatcher и MaxBotManager.
  • Разметка quote. createMarkupElement() бросал «Unknown or unsupported markup type», и сообщение с цитатой не разбиралось. Добавил QuoteMarkup и MarkupType::Quote.

Новое

  • API комментариев к постам каналов: getComments, getCommentById, sendComment, editComment, deleteComment. Модели CommentMessage, CommentMessageBody, CommentLinkedMessage: у комментария нет вложений и публичной ссылки.
  • Новые поля: Recipient::$postId, ContactAttachmentPayload::$hash, description в докблоке ChatPatch.
  • disableLinkPreview в answerOnCallback: параметр POST /answers с августа 2026. Уходит только при true, запросы по умолчанию не меняются.

Deprecated, ничего не удалено

  • getChats: GET /chats не поддерживается с июня 2026.
  • getChatByLink, deleteChat: этих методов нет ни в документации, ни в схеме.
  • addMembers: POST /chats/{chatId}/members ограничен с 9 сентября и удаляется 30 сентября 2026.
  • Модели и enum, которых нет в схеме: inline-кнопка chat, reply-кнопки и ReplyButtonType, Intent, MessageChatCreatedUpdate, Chat::$chatMessageId.

Совместимость

Новые параметры конструкторов необязательные и стоят последними, так что позиционные вызовы не ломаются. toArray() у Recipient и ContactAttachmentPayload теперь содержит post_id и hash, поэтому в двух тестах поправлены ожидаемые массивы.

Как проверял

  • Тесты и PHPStan. Покрытие с --coverage-text осталось 100% на PHP 8.4 и 8.5.
  • Пути, параметры и ответы методов комментариев сверены со схемой и с официальными клиентами на TypeScript и на Go. В TS-клиенте post_id у comment_removed объявлен как string | null, поэтому поле nullable, хотя в схеме оно обязательное.
  • Все шесть JSON-примеров событий комментариев из тестов Go-клиента (stabs/*comment*.json) разбираются без ошибок.
  • На живом API не проверял. bot_admin_permissions_changed описан только в схеме: ни один официальный клиент его пока не реализует.

Не трогал: message_delivered и message_read (их нет в схеме, но они добавлены в #42) и LIBRARY_VERSION.

@BushlanovDev BushlanovDev self-assigned this Sep 30, 2026
smotim added 9 commits October 1, 2026 01:10
The API no longer accepts PATCH /me: it answers "Path /me is not
recognized", so editBotInfo() fails, including for commands. Commands
now have their own endpoint, PATCH /me/commands (editMyCommands in the
official schema); bot name, description and photo are edited on the
MAX partner platform.

- Api::editBotCommands(BotCommand[]): BotCommandsInfo
- BotCommandsInfo model and ModelFactory::createBotCommandsInfo()
- editBotInfo() and BotPatch marked @deprecated
- README coverage map and docs updated
docs/schema.yaml is copied from github.com/max-messenger/api-schema
(1a4a502, 2026-09-18); docs/swagger.json is the same schema
converted to JSON. The previous copies were 0.0.6 and 0.0.1.
Since schema 0.0.33 User.last_activity_time is nullable and not
required. AbstractUser and its subclasses declared it as int, so a
user object without it failed with "Argument BushlanovDev#6 ($lastActivityTime)
must be of type int, null given" and took the whole update with it.
UpdateType already had comment_created, comment_edited,
comment_removed and bot_admin_permissions_changed, but ModelFactory
had no models for them and threw "Unknown or unsupported update type".
Adds the models from schema 0.0.33, maps them in createUpdate() and
adds on*() shortcuts to UpdateDispatcher and MaxBotManager.
- Recipient::$postId: the commented post, set for comments
- ContactAttachmentPayload::$hash: hash of the VCF info
- ChatPatch: document the description field (up to 16000 chars,
  empty string removes it)
- QuoteMarkup and MarkupType::Quote. createMarkupElement() threw
  "Unknown or unsupported markup type" on a quote block, so a message
  with a quote could not be parsed at all

New constructor parameters are optional and last, so existing
positional calls keep working; toArray() of these models now also
carries the new keys.
Schema 0.0.33 adds comments to channel posts:

- GET    /messages/{messageId}/comments               getComments()
- GET    /messages/{messageId}/comments/{commentId}   getCommentById()
- POST   /messages/{messageId}/comments               sendComment()
- PUT    /messages/{messageId}/comments               editComment()
- DELETE /messages/{messageId}/comments               deleteComment()

Comments get their own models (CommentMessage, CommentMessageBody,
CommentLinkedMessage): unlike Message they have no attachments and
no public URL. README coverage map and docs updated.
Methods (per the API changelog and schema 0.0.33):
- getChats(): GET /chats is not supported since June 2026
- getChatByLink(), deleteChat(): no longer documented, absent from
  the schema
- addMembers(): POST /chats/{chatId}/members is limited since
  9 September 2026 and removed on 30 September 2026

Models and enums absent from schema 0.0.33: the chat inline button,
reply buttons and ReplyButtonType, Intent, MessageChatCreatedUpdate
and its handlers, Chat::$chatMessageId.

Only @deprecated tags and docs; nothing is removed, so existing code
keeps working until a major release. README coverage map updated.
POST /answers got the disable_link_preview query parameter in August
2026. It is sent only when true, so default requests are unchanged.
The schema lists post_id as required, but the official TypeScript
client types it as `string | null`. A null would fail with a TypeError
and, unlike an unknown update type, TypeError is not caught while
parsing updates.
@smotim
smotim force-pushed the sync/api-schema-0.0.33 branch from 1ec5b06 to dd00b4c Compare September 30, 2026 20:11
@BushlanovDev
BushlanovDev self-requested a review October 1, 2026 05:43
@BushlanovDev
BushlanovDev merged commit 093fafa into BushlanovDev:master Oct 1, 2026
4 checks passed
BushlanovDev added a commit that referenced this pull request Oct 1, 2026
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