Added api support to upload bot photo.

This commit is contained in:
23rd 2023-04-09 21:39:21 +03:00 committed by John Preston
parent 2276a4c9af
commit bbeefaed9c
1 changed files with 9 additions and 2 deletions

View File

@ -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<MTPInputUser>(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