mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 14:35:36 +01:00
Fix breaking change in TBA 7.2 which removes is_video and is_animated
This commit is contained in:
parent
1952daf5e2
commit
1cca2aaf28
2 changed files with 78 additions and 2 deletions
|
@ -105,8 +105,10 @@ pub enum StickerType {
|
|||
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub struct StickerFormatFlags {
|
||||
/// True, if the sticker is animated
|
||||
#[serde(default)]
|
||||
pub is_animated: bool,
|
||||
/// True, if the sticker is a video sticker
|
||||
#[serde(default)]
|
||||
pub is_video: bool,
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ pub struct StickerSet {
|
|||
#[serde(flatten)]
|
||||
pub kind: StickerType,
|
||||
|
||||
// FIXME: remove it in 7.2 https://core.telegram.org/bots/api#march-31-2024
|
||||
/// Sticker format flags shared by all stickers in this set.
|
||||
#[serde(flatten)]
|
||||
pub flags: StickerFormatFlags,
|
||||
|
@ -112,7 +113,7 @@ mod tests {
|
|||
"is_animated": false,
|
||||
"is_video": false,
|
||||
"type": "regular",
|
||||
"thumb": {
|
||||
"thumbnail": {
|
||||
"file_id": "AAMCAQADFQABYzB4ATH0sqXx351gZ5GpY1Z3Tl8AAlgCAAJ1t4hFbxNCoAg1-akBAAdtAAMpBA",
|
||||
"file_unique_id": "AQADWAIAAnW3iEVy",
|
||||
"file_size": 7698,
|
||||
|
@ -131,7 +132,7 @@ mod tests {
|
|||
"is_animated": false,
|
||||
"is_video": false,
|
||||
"type": "regular",
|
||||
"thumb": {
|
||||
"thumbnail": {
|
||||
"file_id": "AAMCAQADFQABYzB4AcABR8-MuvGagis9Pk6liSAAAs8DAAL2YYBFNbvduoN1p7oBAAdtAAMpBA",
|
||||
"file_unique_id": "AQADzwMAAvZhgEVy",
|
||||
"file_size": 7780,
|
||||
|
@ -152,4 +153,77 @@ mod tests {
|
|||
assert!(set.thumbnail.is_none());
|
||||
assert_eq!(set.stickers.len(), 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
// In TBA7.2 fields `is_video` and `is_audio` are removed, so it's the breaking
|
||||
// change.
|
||||
fn test() {
|
||||
let json = r#"{
|
||||
"name": "tba66_by_memorization_helper_bot",
|
||||
"title": "Teloxide TBA6.6 TEST",
|
||||
"sticker_type": "regular",
|
||||
"contains_masks": false,
|
||||
"stickers": [
|
||||
{
|
||||
"width": 512,
|
||||
"height": 512,
|
||||
"emoji": "\\ud83e\\udd80",
|
||||
"set_name": "tba66_by_memorization_helper_bot",
|
||||
"is_animated": false,
|
||||
"is_video": false,
|
||||
"type": "regular",
|
||||
"thumbnail": {
|
||||
"file_id": "AAMCAgADFQABZmbS1r0a5NWqrPIHJSCabGw3LUwAAh5MAAKRGTlL-H1XHcgw5coBAAdtAAM1BA",
|
||||
"file_unique_id": "AQADHkwAApEZOUty",
|
||||
"file_size": 7786,
|
||||
"width": 320,
|
||||
"height": 320
|
||||
},
|
||||
"thumb": {
|
||||
"file_id": "AAMCAgADFQABZmbS1r0a5NWqrPIHJSCabGw3LUwAAh5MAAKRGTlL-H1XHcgw5coBAAdtAAM1BA",
|
||||
"file_unique_id": "AQADHkwAApEZOUty",
|
||||
"file_size": 7786,
|
||||
"width": 320,
|
||||
"height": 320
|
||||
},
|
||||
"file_id": "CAACAgIAAxUAAWZm0ta9GuTVqqzyByUgmmxsNy1MAAIeTAACkRk5S_h9Vx3IMOXKNQQ",
|
||||
"file_unique_id": "AgADHkwAApEZOUs",
|
||||
"file_size": 11936
|
||||
},
|
||||
{
|
||||
"width": 512,
|
||||
"height": 512,
|
||||
"emoji": "\\ud83e\\udd80",
|
||||
"set_name": "tba66_by_memorization_helper_bot",
|
||||
"is_animated": false,
|
||||
"is_video": false,
|
||||
"type": "regular",
|
||||
"thumbnail": {
|
||||
"file_id": "AAMCAgADFQABZmbS1jN5O3rMp4gsH3eeBPajWVUAAoxIAAKtXDhLhabEKw0iE9sBAAdtAAM1BA",
|
||||
"file_unique_id": "AQADjEgAAq1cOEty",
|
||||
"file_size": 7768,
|
||||
"width": 320,
|
||||
"height": 320
|
||||
},
|
||||
"thumb": {
|
||||
"file_id": "AAMCAgADFQABZmbS1jN5O3rMp4gsH3eeBPajWVUAAoxIAAKtXDhLhabEKw0iE9sBAAdtAAM1BA",
|
||||
"file_unique_id": "AQADjEgAAq1cOEty",
|
||||
"file_size": 7768,
|
||||
"width": 320,
|
||||
"height": 320
|
||||
},
|
||||
"file_id": "CAACAgIAAxUAAWZm0tYzeTt6zKeILB93ngT2o1lVAAKMSAACrVw4S4WmxCsNIhPbNQQ",
|
||||
"file_unique_id": "AgADjEgAAq1cOEs",
|
||||
"file_size": 12092
|
||||
}
|
||||
]
|
||||
}"#;
|
||||
|
||||
let set: StickerSet = serde_json::from_str(json).unwrap();
|
||||
|
||||
assert!(set.is_static());
|
||||
assert!(set.is_regular());
|
||||
assert!(set.thumbnail.is_none());
|
||||
assert_eq!(set.stickers.len(), 2);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue