From eebac051cb3a1f6ba1a02ece19ae24f2d33c8a8a Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 19 Jul 2024 18:11:23 +0300 Subject: [PATCH] Update has_media_previews after changing media previews. --- td/telegram/BotInfoManager.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/td/telegram/BotInfoManager.cpp b/td/telegram/BotInfoManager.cpp index 178cfa67b..905d3e377 100644 --- a/td/telegram/BotInfoManager.cpp +++ b/td/telegram/BotInfoManager.cpp @@ -134,6 +134,7 @@ class GetPreviewMediasQuery final : public Td::ResultHandler { td_->file_manager_->add_file_source(file_id, file_source_id); } } + td_->user_manager_->on_update_bot_has_preview_medias(bot_user_id_, !contents.empty()); promise_.set_value(td_api::make_object(std::move(contents))); } @@ -203,6 +204,7 @@ class BotInfoManager::AddPreviewMediaQuery final : public Td::ResultHandler { td_->file_manager_->add_file_source(file_id, file_source_id); } } + td_->user_manager_->on_update_bot_has_preview_medias(pending_preview_->bot_user_id_, true); pending_preview_->promise_.set_value(get_story_content_object(td_, content.get())); } @@ -223,6 +225,7 @@ class BotInfoManager::AddPreviewMediaQuery final : public Td::ResultHandler { class ReorderPreviewMediasQuery final : public Td::ResultHandler { Promise promise_; + UserId bot_user_id_; public: explicit ReorderPreviewMediasQuery(Promise &&promise) : promise_(std::move(promise)) { @@ -230,6 +233,7 @@ class ReorderPreviewMediasQuery final : public Td::ResultHandler { void send(UserId bot_user_id, telegram_api::object_ptr input_user, const string &language_code, vector> input_media) { + bot_user_id_ = bot_user_id; send_query(G()->net_query_creator().create( telegram_api::bots_reorderPreviewMedias(std::move(input_user), language_code, std::move(input_media)), {{bot_user_id}})); @@ -241,6 +245,7 @@ class ReorderPreviewMediasQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } + td_->user_manager_->on_update_bot_has_preview_medias(bot_user_id_, true); promise_.set_value(Unit()); } @@ -251,6 +256,7 @@ class ReorderPreviewMediasQuery final : public Td::ResultHandler { class DeletePreviewMediaQuery final : public Td::ResultHandler { Promise promise_; + UserId bot_user_id_; public: explicit DeletePreviewMediaQuery(Promise &&promise) : promise_(std::move(promise)) { @@ -258,6 +264,7 @@ class DeletePreviewMediaQuery final : public Td::ResultHandler { void send(UserId bot_user_id, telegram_api::object_ptr input_user, const string &language_code, vector> input_media) { + bot_user_id_ = bot_user_id; send_query(G()->net_query_creator().create( telegram_api::bots_deletePreviewMedia(std::move(input_user), language_code, std::move(input_media)), {{bot_user_id}})); @@ -269,7 +276,7 @@ class DeletePreviewMediaQuery final : public Td::ResultHandler { return on_error(result_ptr.move_as_error()); } - promise_.set_value(Unit()); + td_->user_manager_->reload_user_full(bot_user_id_, std::move(promise_), "DeletePreviewMediaQuery"); } void on_error(Status status) final { @@ -794,6 +801,9 @@ void BotInfoManager::reorder_bot_media_previews(UserId bot_user_id, const string } input_medias.push_back(std::move(input_media)); } + if (input_medias.empty()) { + return promise.set_value(Unit()); + } td_->create_handler(std::move(promise)) ->send(bot_user_id, std::move(input_user), language_code, std::move(input_medias)); }