From 344ace253d7d9187b0b9617e08fe4b3ed46cedab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D1=8B=D1=80=D1=86=D0=B5=D0=B2=20=D0=92=D0=B0=D0=B4?= =?UTF-8?q?=D0=B8=D0=BC=20=D0=98=D0=B3=D0=BE=D1=80=D0=B5=D0=B2=D0=B8=D1=87?= Date: Sun, 7 Apr 2024 18:05:54 +0300 Subject: [PATCH] Fix missing MultipartRequest for create_new_sticker_set --- crates/teloxide-core/src/bot/api.rs | 2 +- .../src/requests/multipart_payload.rs | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/crates/teloxide-core/src/bot/api.rs b/crates/teloxide-core/src/bot/api.rs index 8f0ef1b8..905318b8 100644 --- a/crates/teloxide-core/src/bot/api.rs +++ b/crates/teloxide-core/src/bot/api.rs @@ -1102,7 +1102,7 @@ impl Requester for Bot { ) } - type CreateNewStickerSet = JsonRequest; + type CreateNewStickerSet = MultipartRequest; fn create_new_sticker_set( &self, diff --git a/crates/teloxide-core/src/requests/multipart_payload.rs b/crates/teloxide-core/src/requests/multipart_payload.rs index 1b5b9242..22ec1202 100644 --- a/crates/teloxide-core/src/requests/multipart_payload.rs +++ b/crates/teloxide-core/src/requests/multipart_payload.rs @@ -1,7 +1,7 @@ use crate::{ payloads, requests::Payload, - types::{InputFile, InputFileLike, InputMedia}, + types::{InputFile, InputFileLike, InputMedia, InputSticker}, }; /// Payloads that need to be sent as `multipart/form-data` because they contain @@ -41,3 +41,17 @@ impl MultipartPayload for payloads::EditMessageMediaInline { self.media.files_mut().for_each(|f| f.move_into(into)) } } + +impl MultipartPayload for payloads::CreateNewStickerSet { + fn copy_files(&self, into: &mut dyn FnMut(InputFile)) { + self.stickers + .iter() + .for_each(|InputSticker { sticker: f, .. }: &InputSticker| f.copy_into(into)) + } + + fn move_files(&mut self, into: &mut dyn FnMut(InputFile)) { + self.stickers + .iter_mut() + .for_each(|InputSticker { sticker: f, .. }: &mut InputSticker| f.move_into(into)) + } +}