fix(tgapi): accept string chat boost IDs
This commit is contained in:
+6
-1
@@ -1,6 +1,11 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## Unreleased
|
## v1.0.0-rc.11
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- `chat_boost` update decoding now accepts string `boost_id` values, matching the current Telegram Bot API schema and preventing polling failures on boosted-chat updates.
|
||||||
|
|
||||||
|
## v1.0.0-rc.10
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- `Plugin.AddUpdateHandler` for routing non-command Telegram updates by `tgapi.UpdateType`.
|
- `Plugin.AddUpdateHandler` for routing non-command Telegram updates by `tgapi.UpdateType`.
|
||||||
|
|||||||
+1
-1
@@ -224,7 +224,7 @@ type ChatBoostSource struct {
|
|||||||
// ChatBoost represents a boost added to a chat.
|
// ChatBoost represents a boost added to a chat.
|
||||||
// See https://core.telegram.org/bots/api#chatboost
|
// See https://core.telegram.org/bots/api#chatboost
|
||||||
type ChatBoost struct {
|
type ChatBoost struct {
|
||||||
BoostID int `json:"boost_id"`
|
BoostID string `json:"boost_id"`
|
||||||
AddDate int `json:"add_date"`
|
AddDate int `json:"add_date"`
|
||||||
ExpirationDate int `json:"expiration_date"`
|
ExpirationDate int `json:"expiration_date"`
|
||||||
Source ChatBoostSource `json:"source"`
|
Source ChatBoostSource `json:"source"`
|
||||||
|
|||||||
+23
-1
@@ -37,9 +37,28 @@ func TestUpdateUnmarshalSetsType(t *testing.T) {
|
|||||||
}`,
|
}`,
|
||||||
want: UpdateTypeCallbackQuery,
|
want: UpdateTypeCallbackQuery,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "chat boost",
|
||||||
|
body: `{
|
||||||
|
"update_id": 3,
|
||||||
|
"chat_boost": {
|
||||||
|
"chat": {"id": -1001, "type": "supergroup", "title": "Boosted"},
|
||||||
|
"boost": {
|
||||||
|
"boost_id": "boost-1",
|
||||||
|
"add_date": 1735689600,
|
||||||
|
"expiration_date": 1738291600,
|
||||||
|
"source": {
|
||||||
|
"source": "premium",
|
||||||
|
"user": {"id": 1, "is_bot": false, "first_name": "Test"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`,
|
||||||
|
want: UpdateTypeChatBoost,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "unknown",
|
name: "unknown",
|
||||||
body: `{"update_id":3}`,
|
body: `{"update_id":4}`,
|
||||||
want: UpdateTypeUnknown,
|
want: UpdateTypeUnknown,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -53,6 +72,9 @@ func TestUpdateUnmarshalSetsType(t *testing.T) {
|
|||||||
if update.Type != tt.want {
|
if update.Type != tt.want {
|
||||||
t.Fatalf("unexpected update type: got %q want %q", update.Type, tt.want)
|
t.Fatalf("unexpected update type: got %q want %q", update.Type, tt.want)
|
||||||
}
|
}
|
||||||
|
if tt.want == UpdateTypeChatBoost && update.ChatBoost.Boost.BoostID != "boost-1" {
|
||||||
|
t.Fatalf("unexpected boost id: got %q want %q", update.ChatBoost.Boost.BoostID, "boost-1")
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -2,7 +2,7 @@ package utils
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
// VersionString is the module version string.
|
// VersionString is the module version string.
|
||||||
VersionString = "1.0.0-rc.10"
|
VersionString = "1.0.0-rc.11"
|
||||||
// VersionMajor is the module major version.
|
// VersionMajor is the module major version.
|
||||||
VersionMajor = 1
|
VersionMajor = 1
|
||||||
// VersionMinor is the module minor version.
|
// VersionMinor is the module minor version.
|
||||||
@@ -10,5 +10,5 @@ const (
|
|||||||
// VersionPatch is the module patch version.
|
// VersionPatch is the module patch version.
|
||||||
VersionPatch = 0
|
VersionPatch = 0
|
||||||
// VersionBeta is the prerelease counter for the current version.
|
// VersionBeta is the prerelease counter for the current version.
|
||||||
VersionBeta = 10
|
VersionBeta = 11
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user