Fix callback message, attachment payload tokens, and video response mapping, Issue/chat permission#32
Merged
Conversation
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
There was a problem hiding this comment.
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 token→FileId, url→Url, photo_id→PhotoAttachment.Id), expands the Video model with token/urls/thumbnail, and adds the short view_stats/edit/delete chat-admin permissions.
Changes:
CallbackQueryUpdate.Messageis added and populated from the update;CallbackQuery.Messageis marked[Obsolete]and the converter no longer reads/writes it.AttachmentJsonConvertergainspayload-aware deserializers for image/audio/video/document andVideogainsToken/Urls/Thumbnail.ChatAdminPermissiongainsViewStats,Edit,Deleteshort-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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
контракты 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 и т.п.)