From bbeefaed9c09d2a852dd55c9764fed8691b5f678 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sun, 9 Apr 2023 21:39:21 +0300 Subject: [PATCH] Added api support to upload bot photo. --- Telegram/SourceFiles/api/api_peer_photo.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/api/api_peer_photo.cpp b/Telegram/SourceFiles/api/api_peer_photo.cpp index 5056473d6..a449b2200 100644 --- a/Telegram/SourceFiles/api/api_peer_photo.cpp +++ b/Telegram/SourceFiles/api/api_peer_photo.cpp @@ -367,14 +367,21 @@ void PeerPhoto::ready( done(); } }; - if (peer->isSelf()) { + const auto botUserInput = [&] { + const auto user = peer->asUser(); + return (user && user->botInfo && user->botInfo->canEditInformation) + ? std::make_optional(user->inputUser) + : std::nullopt; + }(); + if (peer->isSelf() || botUserInput) { using Flag = MTPphotos_UploadProfilePhoto::Flag; const auto none = MTPphotos_UploadProfilePhoto::Flags(0); _api.request(MTPphotos_UploadProfilePhoto( MTP_flags((file ? Flag::f_file : none) + | (botUserInput ? Flag::f_bot : none) | (videoSize ? Flag::f_video_emoji_markup : none) | ((type == UploadType::Fallback) ? Flag::f_fallback : none)), - MTPInputUser(), // bot + botUserInput ? (*botUserInput) : MTPInputUser(), // bot file ? (*file) : MTPInputFile(), MTPInputFile(), // video MTPdouble(), // video_start_ts