Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Max.Bot/Types/Converters/UpdateJsonConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ public override Update Read(ref Utf8JsonReader reader, Type typeToConvert, JsonS
update.IsMuted = isMutedElement.GetBoolean();
}

if (root.TryGetProperty("payload", out var payload))
{
update.Payload = payload.GetString();
}
Comment on lines +93 to +96
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
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
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


return update;
}

Expand Down
6 changes: 6 additions & 0 deletions src/Max.Bot/Types/Update.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ public class Update
[JsonPropertyName("message")]
public Message? Message { get; set; }

/// <summary>
/// Gets or sets the payload
/// </summary>
[JsonPropertyName("payload")]
public string? Payload { get; set; }
Comment on lines +62 to +66
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
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.

/// <summary>
/// Gets or sets the callback query in this update.
/// Present in: message_callback.
Expand Down
Loading