Skip to content

Commit 078e044

Browse files
committed
Fix parsing of ChatFullInfo.photo field
1 parent 14e466f commit 078e044

File tree

3 files changed

+34
-41
lines changed

3 files changed

+34
-41
lines changed

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![recursion_limit = "256"]
12
#![cfg_attr(nightly, feature(doc_cfg))]
23
#![doc = include_str!("../README.md")]
34

src/types/chat/full_info/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub struct ChatFullInfo {
6363
/// The time after which all messages sent to the chat will be automatically deleted; in seconds.
6464
pub message_auto_delete_time: Option<Integer>,
6565
/// Chat photo.
66-
pub photo: Option<Vec<ChatPhoto>>,
66+
pub photo: Option<ChatPhoto>,
6767
/// The most recent pinned message (by sending date).
6868
pub pinned_message: Option<Message>,
6969
/// Identifier of the accent color for the chat's profile background.

src/types/chat/full_info/tests.rs

Lines changed: 32 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ fn chat_full_info_channel() {
9393
expected_struct.background_custom_emoji_id = Some(String::from("emoji-id"));
9494
expected_struct.has_protected_content = Some(true);
9595
expected_struct.message_auto_delete_time = Some(86400);
96-
expected_struct.photo = Some(vec![ChatPhoto::new(
96+
expected_struct.photo = Some(ChatPhoto::new(
9797
"big-file-id",
9898
"big-file-unique-id",
9999
"small-file-id",
100100
"small-file-unique-id",
101-
)]);
101+
));
102102
expected_struct.pinned_message = Some(Message::new(
103103
1,
104104
0,
@@ -125,14 +125,12 @@ fn chat_full_info_channel() {
125125
"type": "channel",
126126
"title": "Channel",
127127
"username": "channel_username",
128-
"photo": [
129-
{
130-
"small_file_id": "small-file-id",
131-
"small_file_unique_id": "small-file-unique-id",
132-
"big_file_id": "big-file-id",
133-
"big_file_unique_id": "big-file-unique-id",
134-
}
135-
],
128+
"photo": {
129+
"small_file_id": "small-file-id",
130+
"small_file_unique_id": "small-file-unique-id",
131+
"big_file_id": "big-file-id",
132+
"big_file_unique_id": "big-file-unique-id",
133+
},
136134
"can_send_paid_media": true,
137135
"description": "Description",
138136
"invite_link": "example.com/join/channel",
@@ -191,12 +189,12 @@ fn group_chat() {
191189

192190
let mut expected_struct = expected_struct;
193191
expected_struct.title = Some(String::from("Group"));
194-
expected_struct.photo = Some(vec![ChatPhoto::new(
192+
expected_struct.photo = Some(ChatPhoto::new(
195193
"big-file-id",
196194
"big-file-unique-id",
197195
"small-file-id",
198196
"small-file-unique-id",
199-
)]);
197+
));
200198
expected_struct.invite_link = Some(String::from("example.com/join/group"));
201199
expected_struct.pinned_message = Some(Message::new(
202200
1,
@@ -223,14 +221,12 @@ fn group_chat() {
223221
"id": 1,
224222
"type": "group",
225223
"title": "Group",
226-
"photo": [
227-
{
228-
"small_file_id": "small-file-id",
229-
"small_file_unique_id": "small-file-unique-id",
230-
"big_file_id": "big-file-id",
231-
"big_file_unique_id": "big-file-unique-id",
232-
}
233-
],
224+
"photo": {
225+
"small_file_id": "small-file-id",
226+
"small_file_unique_id": "small-file-unique-id",
227+
"big_file_id": "big-file-id",
228+
"big_file_unique_id": "big-file-unique-id",
229+
},
234230
"invite_link": "example.com/join/group",
235231
"pinned_message": {
236232
"message_id": 1,
@@ -304,12 +300,12 @@ fn private_chat() {
304300
expected_struct.first_name = Some(String::from("John"));
305301
expected_struct.last_name = Some(String::from("Doe"));
306302
expected_struct.username = Some(String::from("john_doe"));
307-
expected_struct.photo = Some(vec![ChatPhoto::new(
303+
expected_struct.photo = Some(ChatPhoto::new(
308304
"big-file-id",
309305
"big-file-unique-id",
310306
"small-file-id",
311307
"small-file-unique-id",
312-
)]);
308+
));
313309
expected_struct.bio = Some(String::from("Bio"));
314310
expected_struct.birthdate = Some(Birthdate::new(1, 1));
315311
expected_struct.business_intro = Some(BusinessIntro::default());
@@ -348,14 +344,12 @@ fn private_chat() {
348344
"username": "john_doe",
349345
"first_name": "John",
350346
"last_name": "Doe",
351-
"photo": [
352-
{
353-
"small_file_id": "small-file-id",
354-
"small_file_unique_id": "small-file-unique-id",
355-
"big_file_id": "big-file-id",
356-
"big_file_unique_id": "big-file-unique-id",
357-
}
358-
],
347+
"photo": {
348+
"small_file_id": "small-file-id",
349+
"small_file_unique_id": "small-file-unique-id",
350+
"big_file_id": "big-file-id",
351+
"big_file_unique_id": "big-file-unique-id",
352+
},
359353
"bio": "Bio",
360354
"birthdate": {
361355
"day": 1,
@@ -433,12 +427,12 @@ fn supergroup_chat() {
433427
let mut expected_struct = expected_struct.clone();
434428
expected_struct.title = Some(String::from("Supergroup Chat"));
435429
expected_struct.username = Some(String::from("supergroup_chat"));
436-
expected_struct.photo = Some(vec![ChatPhoto::new(
430+
expected_struct.photo = Some(ChatPhoto::new(
437431
"big-file-id",
438432
"big-file-unique-id",
439433
"small-file-id",
440434
"small-file-unique-id",
441-
)]);
435+
));
442436
expected_struct.description = Some(String::from("Description"));
443437
expected_struct.emoji_status_custom_emoji_id = Some(String::from("emoji-id"));
444438
expected_struct.emoji_status_expiration_date = Some(0);
@@ -488,14 +482,12 @@ fn supergroup_chat() {
488482
"type": "supergroup",
489483
"title": "Supergroup Chat",
490484
"username": "supergroup_chat",
491-
"photo": [
492-
{
493-
"small_file_id": "small-file-id",
494-
"small_file_unique_id": "small-file-unique-id",
495-
"big_file_id": "big-file-id",
496-
"big_file_unique_id": "big-file-unique-id",
497-
}
498-
],
485+
"photo": {
486+
"small_file_id": "small-file-id",
487+
"small_file_unique_id": "small-file-unique-id",
488+
"big_file_id": "big-file-id",
489+
"big_file_unique_id": "big-file-unique-id",
490+
},
499491
"description": "Description",
500492
"invite_link": "example.com/join/supergroup",
501493
"sticker_set_name": "Sticker Set",

0 commit comments

Comments
 (0)