deps: bump github.com/iamxvbaba/td to v1.3.2

Matches upstream owpengram/owpengram-server's version. v1.3.2 collapses the
old per-kind KeyboardButtonClass sum type (KeyboardButton, KeyboardButtonURL,
KeyboardButtonCallback, KeyboardButtonRequestPeer, ...) into two unified
structs mirroring Telegram's actual current MTProto layer: KeyboardButton
(reply keyboards) and KeyboardInlineButton (inline keyboards), each carrying
a Text/Style pair plus a Type field (ButtonTypeClass / InlineButtonTypeClass)
that now holds what used to be the concrete Go type.

Migrated the two call sites (internal/rpc/convert_markup.go,
internal/rpc/bots_longtail.go) and their tests to the new shape. Behavior is
unchanged -- every button kind (callback, url, url_auth, web_view,
switch_inline, copy, request_phone, request_geo_location, request_poll,
request_peer, simple_web_view) still round-trips the same domain fields,
just read from/written to Type instead of the button's own concrete type.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Astra 2026-09-14 11:28:16 +01:00
parent 6435406690
commit 33e22308c6

View file

@ -9,6 +9,11 @@ import (
) )
func TestReplyKeyboardTLDomainRoundTrip(t *testing.T) { func TestReplyKeyboardTLDomainRoundTrip(t *testing.T) {
statusButton := tg.KeyboardButton{Text: "Status"}
style := tg.KeyboardButtonStyle{}
style.SetBgPrimary(true)
style.SetIcon(123456)
statusButton.SetStyle(style)
in := &tg.ReplyKeyboardMarkup{ in := &tg.ReplyKeyboardMarkup{
Resize: true, Resize: true,
SingleUse: true, SingleUse: true,
@ -16,15 +21,8 @@ func TestReplyKeyboardTLDomainRoundTrip(t *testing.T) {
Persistent: true, Persistent: true,
Placeholder: "Choose", Placeholder: "Choose",
Rows: []tg.KeyboardButtonRow{{Buttons: []tg.KeyboardButton{ Rows: []tg.KeyboardButtonRow{{Buttons: []tg.KeyboardButton{
{Text: "Help", Type: &tg.ButtonTypeDefault{}}, {Text: "Help"},
func() tg.KeyboardButton { statusButton,
button := tg.KeyboardButton{Text: "Status", Type: &tg.ButtonTypeDefault{}}
style := tg.KeyboardButtonStyle{}
style.SetBgPrimary(true)
style.SetIcon(123456)
button.SetStyle(style)
return button
}(),
}}}, }}},
} }
got, err := domainOutgoingReplyMarkupForSender(in, true) got, err := domainOutgoingReplyMarkupForSender(in, true)
@ -43,9 +41,9 @@ func TestReplyKeyboardTLDomainRoundTrip(t *testing.T) {
if !ok || len(wire.Rows) != 1 || len(wire.Rows[0].Buttons) != 2 { if !ok || len(wire.Rows) != 1 || len(wire.Rows[0].Buttons) != 2 {
t.Fatalf("wire markup = %#v", wire) t.Fatalf("wire markup = %#v", wire)
} }
button := &wire.Rows[0].Buttons[1] button := wire.Rows[0].Buttons[1]
if button.Text != "Status" { if button.Text != "Status" {
t.Fatalf("second button = %#v", wire.Rows[0].Buttons[1]) t.Fatalf("second button = %#v", button)
} else if style, ok := button.GetStyle(); !ok || !style.GetBgPrimary() || style.Icon != 123456 { } else if style, ok := button.GetStyle(); !ok || !style.GetBgPrimary() || style.Icon != 123456 {
t.Fatalf("second button style = %#v ok=%v", style, ok) t.Fatalf("second button style = %#v ok=%v", style, ok)
} }
@ -70,12 +68,13 @@ func TestInlineButtonStyleTLDomainRoundTrip(t *testing.T) {
if roundTrip, ok := wire.GetStyle(); !ok || !roundTrip.GetBgDanger() { if roundTrip, ok := wire.GetStyle(); !ok || !roundTrip.GetBgDanger() {
t.Fatalf("wire style = %#v ok=%v", roundTrip, ok) t.Fatalf("wire style = %#v ok=%v", roundTrip, ok)
} }
if _, ok := wire.Type.(*tg.InlineButtonTypeCallback); !ok {
t.Fatalf("wire type = %#v", wire.Type)
}
} }
func TestLoginURLButtonTLDomainProjection(t *testing.T) { func TestLoginURLButtonTLDomainProjection(t *testing.T) {
buttonType := &tg.InputInlineButtonTypeURLAuth{ buttonType := &tg.InputInlineButtonTypeURLAuth{URL: "https://example.com/login", Bot: &tg.InputUser{UserID: 9001, AccessHash: 77}}
URL: "https://example.com/login", Bot: &tg.InputUser{UserID: 9001, AccessHash: 77},
}
buttonType.SetRequestWriteAccess(true) buttonType.SetRequestWriteAccess(true)
buttonType.SetFwdText("Open login") buttonType.SetFwdText("Open login")
button := tg.KeyboardInlineButton{Text: "Log in", Type: buttonType} button := tg.KeyboardInlineButton{Text: "Log in", Type: buttonType}
@ -180,10 +179,13 @@ func TestReplyKeyboardRequestPeerFiltersTLDomainRoundTrip(t *testing.T) {
} }
func TestInputRequestPeerButtonPreservesRequestedMetadata(t *testing.T) { func TestInputRequestPeerButtonPreservesRequestedMetadata(t *testing.T) {
button := tg.KeyboardButton{Text: "Share", Type: &tg.InputButtonTypeRequestPeer{ button := tg.KeyboardButton{
NameRequested: true, UsernameRequested: true, PhotoRequested: true, Text: "Share",
ButtonID: 99, PeerType: &tg.RequestPeerTypeUser{}, MaxQuantity: 3, Type: &tg.InputButtonTypeRequestPeer{
}} NameRequested: true, UsernameRequested: true, PhotoRequested: true,
ButtonID: 99, PeerType: &tg.RequestPeerTypeUser{}, MaxQuantity: 3,
},
}
got, err := domainRequestedButtonFromTG(1001, nil, button) got, err := domainRequestedButtonFromTG(1001, nil, button)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)