Добавлен Payload в Update для поддержки deeplinks в соответствии с до…#17
Добавлен Payload в Update для поддержки deeplinks в соответствии с до…#17KonstantinKaretnikov wants to merge 1 commit intoNanoAgents:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends the MAX Bot update model to expose the payload field from incoming updates, enabling deeplink payload handling per the referenced API documentation.
Changes:
- Added
Payloadproperty toUpdate. - Updated
UpdateJsonConverter.Read(...)to deserialize thepayloadJSON property intoUpdate.Payload.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
src/Max.Bot/Types/Update.cs |
Adds Payload to the core update DTO so consumers can access deeplink payload data. |
src/Max.Bot/Types/Converters/UpdateJsonConverter.cs |
Parses the payload field during update deserialization. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /// <summary> | ||
| /// Gets or sets the payload | ||
| /// </summary> | ||
| [JsonPropertyName("payload")] | ||
| public string? Payload { get; set; } |
There was a problem hiding this comment.
The XML doc for Payload is less specific than other Update properties in this file (most include a trailing period and a Present in: note). Please clarify what this payload represents and in which update_type(s) it is expected (e.g., deeplink payload for bot_started), and align formatting with nearby docs.
| [JsonPropertyName("payload")] | ||
| public string? Payload { get; set; } |
There was a problem hiding this comment.
Update exposes typed wrappers (e.g., BotStartedUpdate) for update-specific fields, but the newly added Update.Payload is not propagated into the BotStartedUpdate wrapper. If consumers use typed wrappers, they still won’t be able to access the deeplink payload; consider adding Payload to BotStartedUpdate and assigning it when building the wrapper.
| if (root.TryGetProperty("payload", out var payload)) | ||
| { | ||
| update.Payload = payload.GetString(); | ||
| } |
There was a problem hiding this comment.
payload.GetString() will throw if the API ever returns a non-string payload (object/number/etc.). Other converters in this repo (e.g., callback/button payload) defensively handle both string and non-string by using ValueKind and falling back to GetRawText(). Please align this parsing to avoid unexpected runtime exceptions.
| if (root.TryGetProperty("payload", out var payload)) | ||
| { | ||
| update.Payload = payload.GetString(); | ||
| } |
There was a problem hiding this comment.
UpdateJsonConverter now reads payload into Update.Payload, but Write(...) does not emit payload. This breaks round-trip serialization (serializing an Update will drop the payload). Please add payload to the Write method when value.Payload is not null/empty.
| if (root.TryGetProperty("payload", out var payload)) | ||
| { | ||
| update.Payload = payload.GetString(); | ||
| } |
There was a problem hiding this comment.
There is already comprehensive unit coverage for Update JSON parsing (including a bot_started test), but it doesn’t cover the newly introduced payload field. Please add a test case that deserializes an update containing payload (and, if Write(...) is updated, a round-trip serialize/deserialize assertion).
…кументацией https://dev.max.ru/docs/chatbots/bots-coding/prepare#Создание%20диплинка%20бота