Skip to content

Добавлен Payload в Update для поддержки deeplinks в соответствии с до…#17

Open
KonstantinKaretnikov wants to merge 1 commit intoNanoAgents:mainfrom
KonstantinKaretnikov:main
Open

Добавлен Payload в Update для поддержки deeplinks в соответствии с до…#17
KonstantinKaretnikov wants to merge 1 commit intoNanoAgents:mainfrom
KonstantinKaretnikov:main

Conversation

@KonstantinKaretnikov
Copy link
Copy Markdown

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 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 Payload property to Update.
  • Updated UpdateJsonConverter.Read(...) to deserialize the payload JSON property into Update.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.

Comment on lines +62 to +66
/// <summary>
/// Gets or sets the payload
/// </summary>
[JsonPropertyName("payload")]
public string? Payload { get; set; }
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +65 to +66
[JsonPropertyName("payload")]
public string? Payload { get; set; }
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +93 to +96
if (root.TryGetProperty("payload", out var payload))
{
update.Payload = payload.GetString();
}
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +93 to +96
if (root.TryGetProperty("payload", out var payload))
{
update.Payload = payload.GetString();
}
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +93 to +96
if (root.TryGetProperty("payload", out var payload))
{
update.Payload = payload.GetString();
}
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

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).

Copilot uses AI. Check for mistakes.
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.

@copilot apply changes based on this feedback

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