diff --git a/td/telegram/StickersManager.cpp b/td/telegram/StickersManager.cpp index de916f360..f3b14c7c7 100644 --- a/td/telegram/StickersManager.cpp +++ b/td/telegram/StickersManager.cpp @@ -2521,6 +2521,7 @@ FileId StickersManager::on_get_sticker(unique_ptr new_sticker, bool rep } if (s->type == StickerType::CustomEmoji) { + s->is_being_reloaded = false; auto custom_emoji_id = get_custom_emoji_id(file_id); if (custom_emoji_id != 0) { custom_emoji_to_sticker_id_[custom_emoji_id] = file_id; @@ -5179,8 +5180,10 @@ void StickersManager::on_load_custom_emoji_from_database(int64 custom_emoji_id, } td_api::object_ptr StickersManager::get_custom_emoji_stickers_object( - const vector &document_ids) const { + const vector &document_ids) { vector> stickers; + auto update_before_date = G()->unix_time() - 86400; + vector reload_document_ids; for (auto document_id : document_ids) { auto it = custom_emoji_to_sticker_id_.find(document_id); if (it == custom_emoji_to_sticker_id_.end()) { @@ -5188,9 +5191,24 @@ td_api::object_ptr StickersManager::get_custom_emoji_stickers_ } auto sticker = get_sticker_object(it->second); if (sticker != nullptr && sticker->type_->get_id() == td_api::stickerTypeCustomEmoji::ID) { + auto s = get_sticker(it->second); + if (s->emoji_receive_date < update_before_date && !s->is_being_reloaded) { + s->is_being_reloaded = true; + reload_document_ids.push_back(document_id); + } stickers.push_back(std::move(sticker)); } } + if (!reload_document_ids.empty()) { + LOG(INFO) << "Reload documents " << reload_document_ids; + auto promise = PromiseCreator::lambda( + [actor_id = + actor_id(this)](Result>> r_documents) mutable { + send_closure(actor_id, &StickersManager::on_get_custom_emoji_documents, std::move(r_documents), + vector(), Promise>()); + }); + td_->create_handler(std::move(promise))->send(std::move(reload_document_ids)); + } return td_api::make_object(std::move(stickers)); } diff --git a/td/telegram/StickersManager.h b/td/telegram/StickersManager.h index 92565c86c..b19521dee 100644 --- a/td/telegram/StickersManager.h +++ b/td/telegram/StickersManager.h @@ -386,6 +386,7 @@ class StickersManager final : public Actor { StickerType type = StickerType::Regular; bool is_premium = false; bool is_from_database = false; + bool is_being_reloaded = false; int32 point = -1; double x_shift = 0; double y_shift = 0; @@ -796,7 +797,7 @@ class StickersManager final : public Actor { static void add_sticker_thumbnail(Sticker *s, PhotoSize thumbnail); - td_api::object_ptr get_custom_emoji_stickers_object(const vector &document_ids) const; + td_api::object_ptr get_custom_emoji_stickers_object(const vector &document_ids); void on_get_custom_emoji_documents(Result>> &&r_documents, vector &&document_ids,