Skip to content

Fix callback message, attachment payload tokens, and video response mapping, Issue/chat permission#32

Merged
CrazyAngelm merged 5 commits into
NanoAgents:mainfrom
sereginsk:issue/ChatPermission
May 13, 2026
Merged

Fix callback message, attachment payload tokens, and video response mapping, Issue/chat permission#32
CrazyAngelm merged 5 commits into
NanoAgents:mainfrom
sereginsk:issue/ChatPermission

Conversation

@sereginsk
Copy link
Copy Markdown

контракты Max.Bot под актуальный формат MAX Bot API.

Callback / message_callback
Добавлено Message? Message { get; set; } в CallbackQueryUpdate.
В Update.CallbackQueryUpdate теперь пробрасывается Message = Update.Message, чтобы mid исходного сообщения не терялся.
CallbackQuery.Message помечено как [Obsolete]
Attachments
AttachmentJsonConverter дополнен поддержкой вложенного формата payload для type="image" | "audio" | "video" | "file":
payload.token маппится в FileId
payload.url маппится в Url
для image поддержан payload.photo_id -> PhotoAttachment.Id
Videos
Video расширена актуальными полями ответа: token, urls, thumbnail.url.
chat permission enum

Добавлены/обновлены юнит-тесты для:
GetVideoAsync нового shape (token, urls, thumbnail)
десериализации attachments из payload-формата (photo_id/token/url, audio.payload.token/url и т.п.)

Sergey Sysalov added 5 commits April 29, 2026 13:11
Move callback message access to CallbackQueryUpdate.Message and mark CallbackQuery.Message obsolete so consumers can reliably read source message mid after deserialization.
Handle MAX payload-style media attachments so image/audio/video/file tokens are mapped to FileId and preserved by consumers that persist attachment tokens.
Prevent deserialization failures of Chats API responses when MAX returns short permission strings
(e.g. view_stats, edit, delete).
…разбирается из attachments[].payload.vcf_info/max_info/hash
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aligns the Max.Bot contracts with the current MAX Bot API shape: it routes Message for message_callback updates through CallbackQueryUpdate, accepts the nested payload form for media attachments (mapping tokenFileId, urlUrl, photo_idPhotoAttachment.Id), expands the Video model with token/urls/thumbnail, and adds the short view_stats/edit/delete chat-admin permissions.

Changes:

  • CallbackQueryUpdate.Message is added and populated from the update; CallbackQuery.Message is marked [Obsolete] and the converter no longer reads/writes it.
  • AttachmentJsonConverter gains payload-aware deserializers for image/audio/video/document and Video gains Token/Urls/Thumbnail.
  • ChatAdminPermission gains ViewStats, Edit, Delete short-form members.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Max.Bot/Types/Update.cs Forwards Message into CallbackQueryUpdate.
src/Max.Bot/Types/CallbackQueryUpdate.cs New Message property for message_callback updates.
src/Max.Bot/Types/CallbackQuery.cs Marks Message as [Obsolete].
src/Max.Bot/Types/Converters/CallbackQueryJsonConverter.cs Drops reading/writing of message field.
src/Max.Bot/Types/Converters/AttachmentJsonConverter.cs Adds payload-form deserialization for photo/audio/video/document/contact.
src/Max.Bot/Types/Video.cs Adds Token, Urls map, and Thumbnail (VideoThumbnail).
src/Max.Bot/Types/Enums/ChatAdminPermission.cs Adds ViewStats, Edit, Delete short-form values.
tests/Max.Bot.Tests/Unit/Types/UpdateTests.cs Asserts Message is mapped onto CallbackQueryUpdate.
tests/Max.Bot.Tests/Unit/Types/CallbackQueryTests.cs Updates tests to expect CallbackQuery.Message to be null.
tests/Max.Bot.Tests/Unit/Types/AttachmentFormatTests.cs Adds payload-form tests for photo and audio attachments.
tests/Max.Bot.Tests/Unit/Api/MessagesApiTests.cs Tests the new video response shape mapping.
tests/Max.Bot.Tests/Unit/Api/ChatsApiTests.cs Tests deserialization of the new short permission strings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@CrazyAngelm CrazyAngelm merged commit b4a38cd into NanoAgents:main May 13, 2026
6 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.

3 participants