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:
parent
ecdb14aaca
commit
7fef8438c5
9 changed files with 166 additions and 174 deletions
|
|
@ -594,7 +594,7 @@ func (r *Router) onBotsRequestWebViewButton(ctx context.Context, req *tg.BotsReq
|
|||
if err != nil {
|
||||
return nil, internalErr()
|
||||
}
|
||||
if req.UserID == nil || req.Button == nil {
|
||||
if req.UserID == nil || req.Button.Type == nil {
|
||||
return nil, buttonDataInvalidErr()
|
||||
}
|
||||
if r.deps.Bots == nil {
|
||||
|
|
@ -622,21 +622,21 @@ func (r *Router) onBotsRequestWebViewButton(ctx context.Context, req *tg.BotsReq
|
|||
return &tg.BotsRequestedButton{WebappReqID: saved.WebAppReqID}, nil
|
||||
}
|
||||
|
||||
func (r *Router) onBotsGetRequestedWebViewButton(ctx context.Context, req *tg.BotsGetRequestedWebViewButtonRequest) (tg.KeyboardButtonClass, error) {
|
||||
func (r *Router) onBotsGetRequestedWebViewButton(ctx context.Context, req *tg.BotsGetRequestedWebViewButtonRequest) (tg.KeyboardButton, error) {
|
||||
userID, _, err := r.currentUserID(ctx)
|
||||
if err != nil {
|
||||
return nil, internalErr()
|
||||
return tg.KeyboardButton{}, internalErr()
|
||||
}
|
||||
bot, err := r.resolveBotUserForViewer(ctx, userID, req.Bot)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return tg.KeyboardButton{}, err
|
||||
}
|
||||
button, found, err := r.deps.Bots.GetRequestedWebViewButton(ctx, bot.ID, userID, req.WebappReqID)
|
||||
if err != nil {
|
||||
return nil, internalErr()
|
||||
return tg.KeyboardButton{}, internalErr()
|
||||
}
|
||||
if !found {
|
||||
return nil, buttonDataInvalidErr()
|
||||
return tg.KeyboardButton{}, buttonDataInvalidErr()
|
||||
}
|
||||
return tgKeyboardButtonRequestPeer(button), nil
|
||||
}
|
||||
|
|
@ -761,21 +761,20 @@ func (r *Router) tgBotPreviewMedia(ctx context.Context, item domain.BotAppPrevie
|
|||
return out
|
||||
}
|
||||
|
||||
func domainRequestedButtonFromTG(botUserID int64, _ tg.InputUserClass, button tg.KeyboardButtonClass) (domain.BotRequestedWebViewButton, error) {
|
||||
func domainRequestedButtonFromTG(botUserID int64, _ tg.InputUserClass, button tg.KeyboardButton) (domain.BotRequestedWebViewButton, error) {
|
||||
var out domain.BotRequestedWebViewButton
|
||||
out.BotUserID = botUserID
|
||||
switch b := button.(type) {
|
||||
case *tg.InputKeyboardButtonRequestPeer:
|
||||
out.Text = strings.TrimSpace(button.Text)
|
||||
switch b := button.Type.(type) {
|
||||
case *tg.InputButtonTypeRequestPeer:
|
||||
out.ButtonID = b.ButtonID
|
||||
out.Text = strings.TrimSpace(b.Text)
|
||||
out.PeerType, out.PeerFilter = domainRequestPeerFilter(b.PeerType)
|
||||
out.MaxQuantity = b.MaxQuantity
|
||||
out.NameRequested = b.NameRequested
|
||||
out.UsernameRequested = b.UsernameRequested
|
||||
out.PhotoRequested = b.PhotoRequested
|
||||
case *tg.KeyboardButtonRequestPeer:
|
||||
case *tg.ButtonTypeRequestPeer:
|
||||
out.ButtonID = b.ButtonID
|
||||
out.Text = strings.TrimSpace(b.Text)
|
||||
out.PeerType, out.PeerFilter = domainRequestPeerFilter(b.PeerType)
|
||||
out.MaxQuantity = b.MaxQuantity
|
||||
default:
|
||||
|
|
@ -800,12 +799,14 @@ func requestPeerTypeName(peerType tg.RequestPeerTypeClass) string {
|
|||
}
|
||||
}
|
||||
|
||||
func tgKeyboardButtonRequestPeer(button domain.BotRequestedWebViewButton) tg.KeyboardButtonClass {
|
||||
return &tg.KeyboardButtonRequestPeer{
|
||||
Text: button.Text,
|
||||
ButtonID: button.ButtonID,
|
||||
PeerType: tgRequestPeerTypeWithFilter(button.PeerType, button.PeerFilter),
|
||||
MaxQuantity: button.MaxQuantity,
|
||||
func tgKeyboardButtonRequestPeer(button domain.BotRequestedWebViewButton) tg.KeyboardButton {
|
||||
return tg.KeyboardButton{
|
||||
Text: button.Text,
|
||||
Type: &tg.ButtonTypeRequestPeer{
|
||||
ButtonID: button.ButtonID,
|
||||
PeerType: tgRequestPeerTypeWithFilter(button.PeerType, button.PeerFilter),
|
||||
MaxQuantity: button.MaxQuantity,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue